kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe
@ 2020-09-21 12:52 Dan Carpenter
  2020-09-21 16:48 ` Dr. David Alan Gilbert
  2020-09-23 16:40 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-09-21 12:52 UTC (permalink / raw)
  To: Jean Delvare, Dr. David Alan Gilbert
  Cc: Guenter Roeck, linux-hwmon, kernel-janitors

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(-)

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe
  2020-09-21 12:52 [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe Dan Carpenter
@ 2020-09-21 16:48 ` Dr. David Alan Gilbert
  2020-09-23 16:40 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2020-09-21 16:48 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jean Delvare, Guenter Roeck, linux-hwmon, kernel-janitors

* 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
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe
  2020-09-21 12:52 [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe Dan Carpenter
  2020-09-21 16:48 ` Dr. David Alan Gilbert
@ 2020-09-23 16:40 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-09-23 16:40 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jean Delvare, Dr. David Alan Gilbert, linux-hwmon, kernel-janitors

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-23 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 12:52 [PATCH] hwmon: (w83627ehf) Fix a resource leak in probe Dan Carpenter
2020-09-21 16:48 ` Dr. David Alan Gilbert
2020-09-23 16:40 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).