[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211029042812.GA818647@roeck-us.net>
Date: Thu, 28 Oct 2021 21:28:12 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Wan Jiabing <wanjiabing@...o.com>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org, jiabing.wan@...com
Subject: Re: [PATCH] hwmon: (nct7802) Add of_node_put() before return
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@...o.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;
> + }
> }
> }
>
Powered by blists - more mailing lists