public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: Fabio Estevam <festevam@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe()
Date: Thu, 07 May 2015 02:13:57 +0300	[thread overview]
Message-ID: <554AA035.3060407@ispras.ru> (raw)
In-Reply-To: <CAOMZO5C-Hv=oE4gb32OssGhH-5S4mwOLnwL1HEjCEZ82akSeRg@mail.gmail.com>

On 07.05.2015 01:32, Fabio Estevam wrote:
> On Wed, May 6, 2015 at 7:14 PM, Alexey Khoroshilov
> <khoroshilov@ispras.ru> wrote:
> 
>> Not exactly. Other calls are after
>>   indio_dev->channels = channels;
>> So,
>> error_free_dev_mem:
>>         kfree(indio_dev->channels);
>> works for them well.
> 
> indio_dev is allocated using devm_ , so you don't need to free it.
> 
> Your patch is not correct because you only  kfree(channels) in the
> prox_parse_report() error case, but you missed the other subsequent
> functions.
> 

No! The other subsequent functions are AFTER (prox_parse_report() error
case is the only BEFORE)
  indio_dev->channels = channels;

and all consequent error cases comes to error_free_dev_mem, where

error_free_dev_mem:
       kfree(indio_dev->channels);

that is equivalent to kfree(channels);

--
Alexey



  reply	other threads:[~2015-05-06 23:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 21:48 [PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe() Alexey Khoroshilov
2015-05-06 22:00 ` Fabio Estevam
2015-05-06 22:14   ` Alexey Khoroshilov
2015-05-06 22:32     ` Fabio Estevam
2015-05-06 23:13       ` Alexey Khoroshilov [this message]
2015-05-07  7:43   ` Daniel Baluta
2015-05-07  9:18     ` Jonathan Cameron

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=554AA035.3060407@ispras.ru \
    --to=khoroshilov@ispras.ru \
    --cc=festevam@gmail.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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