lkml.org 
[lkml]   [2015]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe()
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




\
 
 \ /
  Last update: 2015-05-07 01:41    [W:0.051 / U:5.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site