linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (nct7802) Add of_node_put() before return
@ 2021-10-29  2:49 Wan Jiabing
  2021-10-29  4:28 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Wan Jiabing @ 2021-10-29  2:49 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel
  Cc: jiabing.wan, Wan Jiabing

Fix following coccicheck warning:
./drivers/hwmon/nct7802.c:1152:2-24: WARNING: Function
for_each_child_of_node should have of_node_put() before return.

Early exits from for_each_child_of_node should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/hwmon/nct7802.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
index d56f78327619..d1eeef02b6dc 100644
--- a/drivers/hwmon/nct7802.c
+++ b/drivers/hwmon/nct7802.c
@@ -1152,8 +1152,10 @@ static int nct7802_configure_channels(struct device *dev,
 		for_each_child_of_node(dev->of_node, node) {
 			err = nct7802_get_channel_config(dev, node, &mode_mask,
 							 &mode_val);
-			if (err)
+			if (err) {
+				of_node_put(node);
 				return err;
+			}
 		}
 	}
 
-- 
2.20.1


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

* Re: [PATCH] hwmon: (nct7802) Add of_node_put() before return
  2021-10-29  2:49 [PATCH] hwmon: (nct7802) Add of_node_put() before return Wan Jiabing
@ 2021-10-29  4:28 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-10-29  4:28 UTC (permalink / raw)
  To: Wan Jiabing; +Cc: Jean Delvare, linux-hwmon, linux-kernel, jiabing.wan

On Thu, Oct 28, 2021 at 10:49:18PM -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> ./drivers/hwmon/nct7802.c:1152:2-24: WARNING: Function
> for_each_child_of_node should have of_node_put() before return.
> 
> Early exits from for_each_child_of_node should decrement the
> node reference counter.
> 
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/nct7802.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c
> index d56f78327619..d1eeef02b6dc 100644
> --- a/drivers/hwmon/nct7802.c
> +++ b/drivers/hwmon/nct7802.c
> @@ -1152,8 +1152,10 @@ static int nct7802_configure_channels(struct device *dev,
>  		for_each_child_of_node(dev->of_node, node) {
>  			err = nct7802_get_channel_config(dev, node, &mode_mask,
>  							 &mode_val);
> -			if (err)
> +			if (err) {
> +				of_node_put(node);
>  				return err;
> +			}
>  		}
>  	}
>  

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

end of thread, other threads:[~2021-10-29  4:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29  2:49 [PATCH] hwmon: (nct7802) Add of_node_put() before return Wan Jiabing
2021-10-29  4:28 ` 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).