linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>,
	Himangi Saraogi <himangi774@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: question regarding drivers/staging/iio/adc/ad7280a.c
Date: Wed, 16 Jul 2014 13:14:23 +0200	[thread overview]
Message-ID: <53C65E8F.2080708@metafoo.de> (raw)
In-Reply-To: <53C5656F.9030200@kernel.org>

On 07/15/2014 07:31 PM, Jonathan Cameron wrote:
> On 14/07/14 21:31, Himangi Saraogi wrote:
>> Hi,
>>
>> The code seems to have a memory leak. The function ad7280_attr_init
>> calls kasprintf a number of times, which calls kmalloc (or more
>> precisely kmalloc_track_caller), but this data does not ever seem to
>> be freed. I propose to introduce a devm_  version of kasprintf, which
>> will be useful for other files also. I am not very sure that will it
>> be useful to introduce a bunch of kfrees, just to remove the memory
>> leaks immediately, but I think it would be safer just to devm
>> everything, so then one is sure that everything is freed as it should
>> be, in the right order.
>>
> The question here is whether such a memory leak squashing would be
> worth applying to stable.  Personally I'd go with no. In which case
> feel free to fix it via the introduction of a devm version.

devm is probably fine here.

The long term fix should be to switch the driver to use 
iio_chan_spec_ext_info infrastructure which will handle the allocation and 
freeing internally in the IIO framework.

- Lars


  reply	other threads:[~2014-07-16 11:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 20:31 question regarding drivers/staging/iio/adc/ad7280a.c Himangi Saraogi
2014-07-15 17:31 ` Jonathan Cameron
2014-07-16 11:14   ` Lars-Peter Clausen [this message]
2014-07-17 18:10     ` Himangi Saraogi
2014-07-17 20:58       ` Greg Kroah-Hartman
2014-07-18  1:27         ` Greg Kroah-Hartman

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=53C65E8F.2080708@metafoo.de \
    --to=lars@metafoo.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=himangi774@gmail.com \
    --cc=jic23@kernel.org \
    --cc=julia.lawall@lip6.fr \
    --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;
as well as URLs for NNTP newsgroup(s).