Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: core: fix memleak in iio_device_register_sysfs
Date: Sun, 17 Dec 2023 13:28:00 +0000	[thread overview]
Message-ID: <20231217132800.27e83a01@jic23-huawei> (raw)
In-Reply-To: <20231210133228.5fd425ea@jic23-huawei>

On Sun, 10 Dec 2023 13:32:28 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Fri,  8 Dec 2023 15:31:19 +0800
> Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
> 
> > When iio_device_register_sysfs_group() fails, we should
> > free iio_dev_opaque->chan_attr_group.attrs to prevent
> > potential memleak.
> > 
> > Fixes: 32f171724e5c ("iio: core: rework iio device group creation")
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>  
> Hi.
> 
> Looks good to me, but I'd like to leave this one on the list a little
> longer to see if anyone else has comments.
> 
Guess no comments!

Applied to the fixes-togreg branch of iio.git.  I might not get another
fixes request out far enough in advance of the merge window in which case
this will go in around then instead.

Also marked for stable

Jonathan

> Jonathan
> 
> > ---
> >  drivers/iio/industrialio-core.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > index c77745b594bd..e6d3d07a4c83 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -1581,10 +1581,13 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev)
> >  	ret = iio_device_register_sysfs_group(indio_dev,
> >  					      &iio_dev_opaque->chan_attr_group);
> >  	if (ret)
> > -		goto error_clear_attrs;
> > +		goto error_free_chan_attrs;
> >  
> >  	return 0;
> >  
> > +error_free_chan_attrs:
> > +	kfree(iio_dev_opaque->chan_attr_group.attrs);
> > +	iio_dev_opaque->chan_attr_group.attrs = NULL;
> >  error_clear_attrs:
> >  	iio_free_chan_devattr_list(&iio_dev_opaque->channel_attr_list);
> >    
> 
> 


  reply	other threads:[~2023-12-17 13:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  7:31 [PATCH] iio: core: fix memleak in iio_device_register_sysfs Dinghao Liu
2023-12-10 13:32 ` Jonathan Cameron
2023-12-17 13:28   ` Jonathan Cameron [this message]
2024-02-11 19:16     ` andy.shevchenko
2024-02-11 19:37       ` Jonathan Cameron
2024-02-11 20:19         ` Andy Shevchenko

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=20231217132800.27e83a01@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=alexandru.ardelean@analog.com \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=lars@metafoo.de \
    --cc=linux-iio@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