Message ID | 20200921125212.GA1128194@mwanda (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | hwmon: (w83627ehf) Fix a resource leak in probe | expand |
* Dan Carpenter (dan.carpenter@oracle.com) wrote: > Smatch has a new check for resource leaks which found a bug in probe: > > drivers/hwmon/w83627ehf.c:2417 w83627ehf_probe() > warn: 'res->start' not released on lines: 2412. > > We need to clean up if devm_hwmon_device_register_with_info() fails. > > Fixes: 266cd5835947 ("hwmon: (w83627ehf) convert to with_info interface") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Yeh that looks right to me; thanks! Reviewed-by: Dr. David Alan Gilbert <linux@treblig.org> > --- > drivers/hwmon/w83627ehf.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c > index 5a5120121e50..3964ceab2817 100644 > --- a/drivers/hwmon/w83627ehf.c > +++ b/drivers/hwmon/w83627ehf.c > @@ -1951,8 +1951,12 @@ static int w83627ehf_probe(struct platform_device *pdev) > data, > &w83627ehf_chip_info, > w83627ehf_groups); > + if (IS_ERR(hwmon_dev)) { > + err = PTR_ERR(hwmon_dev); > + goto exit_release; > + } > > - return PTR_ERR_OR_ZERO(hwmon_dev); > + return 0; > > exit_release: > release_region(res->start, IOREGION_LENGTH); > -- > 2.28.0 >
On Mon, Sep 21, 2020 at 03:52:12PM +0300, Dan Carpenter wrote: > Smatch has a new check for resource leaks which found a bug in probe: > > drivers/hwmon/w83627ehf.c:2417 w83627ehf_probe() > warn: 'res->start' not released on lines: 2412. > > We need to clean up if devm_hwmon_device_register_with_info() fails. > > Fixes: 266cd5835947 ("hwmon: (w83627ehf) convert to with_info interface") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > Reviewed-by: Dr. David Alan Gilbert <linux@treblig.org> Applied. Thanks, Guenter > --- > drivers/hwmon/w83627ehf.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c > index 5a5120121e50..3964ceab2817 100644 > --- a/drivers/hwmon/w83627ehf.c > +++ b/drivers/hwmon/w83627ehf.c > @@ -1951,8 +1951,12 @@ static int w83627ehf_probe(struct platform_device *pdev) > data, > &w83627ehf_chip_info, > w83627ehf_groups); > + if (IS_ERR(hwmon_dev)) { > + err = PTR_ERR(hwmon_dev); > + goto exit_release; > + } > > - return PTR_ERR_OR_ZERO(hwmon_dev); > + return 0; > > exit_release: > release_region(res->start, IOREGION_LENGTH);
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 5a5120121e50..3964ceab2817 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -1951,8 +1951,12 @@ static int w83627ehf_probe(struct platform_device *pdev) data, &w83627ehf_chip_info, w83627ehf_groups); + if (IS_ERR(hwmon_dev)) { + err = PTR_ERR(hwmon_dev); + goto exit_release; + } - return PTR_ERR_OR_ZERO(hwmon_dev); + return 0; exit_release: release_region(res->start, IOREGION_LENGTH);
Smatch has a new check for resource leaks which found a bug in probe: drivers/hwmon/w83627ehf.c:2417 w83627ehf_probe() warn: 'res->start' not released on lines: 2412. We need to clean up if devm_hwmon_device_register_with_info() fails. Fixes: 266cd5835947 ("hwmon: (w83627ehf) convert to with_info interface") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/hwmon/w83627ehf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)