All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Stefan Wahren <stefan.wahren@i2se.com>,
	Marek Vasut <marex@denx.de>, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	Juergen Borleis <jbe@pengutronix.de>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH RFT 1/5] iio: mxs-lradc: fix memory leak
Date: Tue, 19 Apr 2016 19:58:50 +0100	[thread overview]
Message-ID: <57167FEA.2030700@kernel.org> (raw)
In-Reply-To: <5716348F.70200@i2se.com>

On 19/04/16 14:37, Stefan Wahren wrote:
> Hi Marek,
> 
> Am 19.04.2016 um 12:32 schrieb Marek Vasut:
>> On 04/19/2016 08:33 AM, Stefan Wahren wrote:
>>> Hi Marek,
>>>
>>> Am 18.04.2016 um 19:16 schrieb Marek Vasut:
>>>> On 04/17/2016 12:08 PM, Jonathan Cameron wrote:
>>>>> On 14/04/16 21:01, Marek Vasut wrote:
>>>>>> On 04/14/2016 05:48 PM, Stefan Wahren wrote:
>>>>>>> After successful touchscreen registration the input device was
>>>>>>> never freed. So fix this issue by using devm_input_allocate_device().
>>>>>>>
>>>>>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>>>>>>> ---
>>>>>>>  drivers/iio/adc/mxs-lradc.c |    8 ++------
>>>>>>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c
>>>>>>> index 33051b8..0576953 100644
>>>>>>> --- a/drivers/iio/adc/mxs-lradc.c
>>>>>>> +++ b/drivers/iio/adc/mxs-lradc.c
>>>>>>> @@ -1109,12 +1109,11 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
>>>>>>>  {
>>>>>>>  	struct input_dev *input;
>>>>>>>  	struct device *dev = lradc->dev;
>>>>>>> -	int ret;
>>>>>>>  
>>>>>>>  	if (!lradc->use_touchscreen)
>>>>>>>  		return 0;
>>>>>>>  
>>>>>>> -	input = input_allocate_device();
>>>>>>> +	input = devm_input_allocate_device(dev);
>>>>>>>  	if (!input)
>>>>>>>  		return -ENOMEM;
>>>>>>>  
>>>>>>> @@ -1134,11 +1133,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
>>>>>>>  
>>>>>>>  	lradc->ts_input = input;
>>>>>>>  	input_set_drvdata(input, lradc);
>>>>>>> -	ret = input_register_device(input);
>>>>>>> -	if (ret)
>>>>>>> -		input_free_device(lradc->ts_input);
>>>>>>>  
>>>>>>> -	return ret;
>>>>>>> +	return input_register_device(input);
>>>>>>>  }
>>>>>>>  
>>>>>>>  static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
>>>>>>>
>>>>>> Nice find.
>>>>>>
>>>>>> Looks like at91_adc.c and exynos_adc.c suffer from the exact same issue.
>>>>>> The leak looks a bit more severe on exynos even, exynos_adc_ts_init()
>>>>>> could use a proper fail path. Do you want to send patches or shall I ?
>>>>>>
>>>>> As this has been there a long time I'm not going to rush it in as a fix.
>>>> I did take a proper look today and it seems they do the right thing
>>>> afterall. I checked them with kmemleak too to be sure.
>>> thanks, input_unregister_device already free the memory.
>>>
>>> Sorry for the mess :-(
>>>
>>> I think it would be the best to remove / revert this patch.
Removed it.  Had never pushed this out in a non rebasable branch so
easiest just to drop it.

Jonathan
>> This one? Why exactly? Please elaborate some more, so it's possible to
>> understand the reasoning :)
>>
>>
> 
> as you already pointed out this is not a memory leak, because
> input_unregister_device free the input device. So the commit message is
> incorrect.
> 
> This commit also simplifies the code but in this case we should also
> remove input_unregister_device.
> 
> Regards
> Stefan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


WARNING: multiple messages have this Message-ID (diff)
From: jic23@kernel.org (Jonathan Cameron)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFT 1/5] iio: mxs-lradc: fix memory leak
Date: Tue, 19 Apr 2016 19:58:50 +0100	[thread overview]
Message-ID: <57167FEA.2030700@kernel.org> (raw)
In-Reply-To: <5716348F.70200@i2se.com>

On 19/04/16 14:37, Stefan Wahren wrote:
> Hi Marek,
> 
> Am 19.04.2016 um 12:32 schrieb Marek Vasut:
>> On 04/19/2016 08:33 AM, Stefan Wahren wrote:
>>> Hi Marek,
>>>
>>> Am 18.04.2016 um 19:16 schrieb Marek Vasut:
>>>> On 04/17/2016 12:08 PM, Jonathan Cameron wrote:
>>>>> On 14/04/16 21:01, Marek Vasut wrote:
>>>>>> On 04/14/2016 05:48 PM, Stefan Wahren wrote:
>>>>>>> After successful touchscreen registration the input device was
>>>>>>> never freed. So fix this issue by using devm_input_allocate_device().
>>>>>>>
>>>>>>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>>>>>>> ---
>>>>>>>  drivers/iio/adc/mxs-lradc.c |    8 ++------
>>>>>>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c
>>>>>>> index 33051b8..0576953 100644
>>>>>>> --- a/drivers/iio/adc/mxs-lradc.c
>>>>>>> +++ b/drivers/iio/adc/mxs-lradc.c
>>>>>>> @@ -1109,12 +1109,11 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
>>>>>>>  {
>>>>>>>  	struct input_dev *input;
>>>>>>>  	struct device *dev = lradc->dev;
>>>>>>> -	int ret;
>>>>>>>  
>>>>>>>  	if (!lradc->use_touchscreen)
>>>>>>>  		return 0;
>>>>>>>  
>>>>>>> -	input = input_allocate_device();
>>>>>>> +	input = devm_input_allocate_device(dev);
>>>>>>>  	if (!input)
>>>>>>>  		return -ENOMEM;
>>>>>>>  
>>>>>>> @@ -1134,11 +1133,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
>>>>>>>  
>>>>>>>  	lradc->ts_input = input;
>>>>>>>  	input_set_drvdata(input, lradc);
>>>>>>> -	ret = input_register_device(input);
>>>>>>> -	if (ret)
>>>>>>> -		input_free_device(lradc->ts_input);
>>>>>>>  
>>>>>>> -	return ret;
>>>>>>> +	return input_register_device(input);
>>>>>>>  }
>>>>>>>  
>>>>>>>  static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
>>>>>>>
>>>>>> Nice find.
>>>>>>
>>>>>> Looks like at91_adc.c and exynos_adc.c suffer from the exact same issue.
>>>>>> The leak looks a bit more severe on exynos even, exynos_adc_ts_init()
>>>>>> could use a proper fail path. Do you want to send patches or shall I ?
>>>>>>
>>>>> As this has been there a long time I'm not going to rush it in as a fix.
>>>> I did take a proper look today and it seems they do the right thing
>>>> afterall. I checked them with kmemleak too to be sure.
>>> thanks, input_unregister_device already free the memory.
>>>
>>> Sorry for the mess :-(
>>>
>>> I think it would be the best to remove / revert this patch.
Removed it.  Had never pushed this out in a non rebasable branch so
easiest just to drop it.

Jonathan
>> This one? Why exactly? Please elaborate some more, so it's possible to
>> understand the reasoning :)
>>
>>
> 
> as you already pointed out this is not a memory leak, because
> input_unregister_device free the input device. So the commit message is
> incorrect.
> 
> This commit also simplifies the code but in this case we should also
> remove input_unregister_device.
> 
> Regards
> Stefan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2016-04-19 18:58 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 15:48 [PATCH RFT 0/5] iio: mxs-lradc: fix leak and implement PM ops Stefan Wahren
2016-04-14 15:48 ` Stefan Wahren
2016-04-14 15:48 ` [PATCH RFT 1/5] iio: mxs-lradc: fix memory leak Stefan Wahren
2016-04-14 15:48   ` Stefan Wahren
2016-04-14 20:01   ` Marek Vasut
2016-04-14 20:01     ` Marek Vasut
2016-04-17 10:08     ` Jonathan Cameron
2016-04-17 10:08       ` Jonathan Cameron
2016-04-18 17:16       ` Marek Vasut
2016-04-18 17:16         ` Marek Vasut
2016-04-19  6:33         ` Stefan Wahren
2016-04-19  6:33           ` Stefan Wahren
2016-04-19 10:32           ` Marek Vasut
2016-04-19 10:32             ` Marek Vasut
2016-04-19 13:37             ` Stefan Wahren
2016-04-19 13:37               ` Stefan Wahren
2016-04-19 18:58               ` Jonathan Cameron [this message]
2016-04-19 18:58                 ` Jonathan Cameron
2016-04-19 19:29               ` Marek Vasut
2016-04-19 19:29                 ` Marek Vasut
2016-04-18  6:19     ` Stefan Wahren
2016-04-18  6:19       ` Stefan Wahren
2016-04-18 10:45       ` Marek Vasut
2016-04-18 10:45         ` Marek Vasut
2016-04-14 15:48 ` [PATCH RFT 2/5] iio: mxs-lradc: move TS config into suitable function Stefan Wahren
2016-04-14 15:48   ` Stefan Wahren
2016-04-14 20:01   ` Marek Vasut
2016-04-14 20:01     ` Marek Vasut
2016-04-17 10:13     ` Jonathan Cameron
2016-04-17 10:13       ` Jonathan Cameron
2016-04-17 12:19       ` Torokhov
2016-04-17 12:19         ` Torokhov
     [not found]       ` <571361DD.1090001-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-04-18  6:26         ` Stefan Wahren
2016-04-18  6:26           ` Stefan Wahren
2016-04-18  6:26           ` Stefan Wahren
2016-04-14 15:48 ` [PATCH RFT 3/5] iio: mxs-lradc: move STMP reset out of ADC init Stefan Wahren
2016-04-14 15:48   ` Stefan Wahren
2016-04-15  6:48   ` Juergen Borleis
2016-04-15  6:48     ` Juergen Borleis
2016-04-15 10:12     ` Marek Vasut
2016-04-15 10:12       ` Marek Vasut
2016-04-17 10:24       ` Jonathan Cameron
2016-04-17 10:24         ` Jonathan Cameron
2016-04-14 15:48 ` [PATCH RFT 4/5] iio: mxs-lradc: disable only mapped channels in mxs_lradc_hw_stop Stefan Wahren
2016-04-14 15:48   ` Stefan Wahren
2016-04-17 10:47   ` Jonathan Cameron
2016-04-17 10:47     ` Jonathan Cameron
     [not found]     ` <571369AA.8060106-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-04-18  6:36       ` Stefan Wahren
2016-04-18  6:36         ` Stefan Wahren
2016-04-18  6:36         ` Stefan Wahren
2016-04-14 15:48 ` [PATCH RFT 5/5] iio: mxs-lradc: implement suspend/resume support Stefan Wahren
2016-04-14 15:48   ` Stefan Wahren
2016-04-17 10:48   ` Jonathan Cameron
2016-04-17 10:48     ` Jonathan Cameron
2016-04-14 19:55 ` [PATCH RFT 0/5] iio: mxs-lradc: fix leak and implement PM ops Marek Vasut
2016-04-14 19:55   ` Marek Vasut
2016-04-18  6:17   ` Stefan Wahren
2016-04-18  6:17     ` Stefan Wahren
     [not found]     ` <57147BEF.4070606-eS4NqCHxEME@public.gmane.org>
2016-04-18 10:44       ` Marek Vasut
2016-04-18 10:44         ` Marek Vasut
2016-04-18 10:44         ` Marek Vasut

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=57167FEA.2030700@kernel.org \
    --to=jic23@kernel.org \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=fabio.estevam@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbe@pengutronix.de \
    --cc=knaack.h@gmx.de \
    --cc=ksenija.stanojevic@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=pmeerw@pmeerw.net \
    --cc=stefan.wahren@i2se.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.