public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Alexandru Tachici <alexandru.tachici@analog.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH v1 1/1] hwmon: (ltc2992) Put fwnode in error case during ->probe()
Date: Mon, 10 May 2021 08:02:28 -0700	[thread overview]
Message-ID: <20210510150228.GA1997561@roeck-us.net> (raw)
In-Reply-To: <20210510100136.3303142-1-andy.shevchenko@gmail.com>

On Mon, May 10, 2021 at 01:01:36PM +0300, Andy Shevchenko wrote:
> In each iteration fwnode_for_each_available_child_node() bumps a reference
> counting of a loop variable followed by dropping in on a next iteration,
> 
> Since in error case the loop is broken, we have to drop a reference count
> by ourselves. Do it for port_fwnode in error case during ->probe().
> 
> Fixes: b0bd407e94b0 ("hwmon: (ltc2992) Add support")
> Cc: Alexandru Tachici <alexandru.tachici@analog.com>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/ltc2992.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c
> index 4382105bf142..2a4bed0ab226 100644
> --- a/drivers/hwmon/ltc2992.c
> +++ b/drivers/hwmon/ltc2992.c
> @@ -900,11 +900,15 @@ static int ltc2992_parse_dt(struct ltc2992_state *st)
>  
>  	fwnode_for_each_available_child_node(fwnode, child) {
>  		ret = fwnode_property_read_u32(child, "reg", &addr);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			fwnode_handle_put(child);
>  			return ret;
> +		}
>  
> -		if (addr > 1)
> +		if (addr > 1) {
> +			fwnode_handle_put(child);
>  			return -EINVAL;
> +		}
>  
>  		ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val);
>  		if (!ret)

      reply	other threads:[~2021-05-10 15:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 10:01 [PATCH v1 1/1] hwmon: (ltc2992) Put fwnode in error case during ->probe() Andy Shevchenko
2021-05-10 15:02 ` Guenter Roeck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210510150228.GA1997561@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=alexandru.tachici@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox