Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Zeng Heng <zengheng4@huawei.com>,
	linus.walleij@linaro.org, linux-kernel@vger.kernel.org,
	xiexiuqi@huawei.com, linux-gpio@vger.kernel.org,
	weiyongjun1@huawei.com, liwei391@huawei.com
Subject: Re: [PATCH] pinctrl: devicetree: fix refcount leak in pinctrl_dt_to_map()
Date: Wed, 17 Apr 2024 20:12:23 +0300	[thread overview]
Message-ID: <ZiAC9zzSWume8063@smile.fi.intel.com> (raw)
In-Reply-To: <d80e09d8-5f35-4865-9fe8-195b86527972@moroto.mountain>

On Wed, Apr 17, 2024 at 06:38:46PM +0300, Dan Carpenter wrote:
> On Wed, Apr 17, 2024 at 06:30:59PM +0300, Andy Shevchenko wrote:
> > On Mon, Apr 15, 2024 at 06:53:28PM +0800, Zeng Heng wrote:

...

> > >  	for (state = 0; ; state++) {
> > >  		/* Retrieve the pinctrl-* property */
> > >  		propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state);
> > > -		if (!propname)
> > > -			return -ENOMEM;
> > > +		if (!propname) {
> > > +			ret = -ENOMEM;
> > > +			goto err;
> > > +		}
> > >  		prop = of_find_property(np, propname, &size);
> > >  		kfree(propname);
> > >  		if (!prop) {
> > >  			if (state == 0) {
> > > -				of_node_put(np);
> > > -				return -ENODEV;
> > > +				ret = -ENODEV;
> > > +				goto err;
> > 
> > Has it been tested? How on earth is this a correct change?
> > 
> > We iterate over state numbers until we have properties available. This chunk is
> > _successful_ exit path, we may not free parsed maps! Am I wrong?
> 
> In this path state == 0 so we haven't had a successful iteration yet.

Ah, indeed, this is not a status. Okay, makes sense, but calling that free
function for the purpose of the putting of_node seems an overkill...

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-04-17 17:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 10:53 [PATCH] pinctrl: devicetree: fix refcount leak in pinctrl_dt_to_map() Zeng Heng
2024-04-15 11:08 ` Dan Carpenter
2024-04-15 16:36 ` Markus Elfring
2024-04-16 13:33 ` Linus Walleij
2024-04-17 15:30 ` Andy Shevchenko
2024-04-17 15:38   ` Dan Carpenter
2024-04-17 17:12     ` Andy Shevchenko [this message]
2024-04-17 17:49       ` Dan Carpenter
2024-04-18 10:05         ` Andy Shevchenko
2024-04-19 13:24         ` Linus Walleij

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=ZiAC9zzSWume8063@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=xiexiuqi@huawei.com \
    --cc=zengheng4@huawei.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).