Message ID | 1460648909-2657-2-git-send-email-stefan.wahren@i2se.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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 ?
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 suspect no platform is probing and removing it enough to get a significant amount of memory leaked. Good to clear it up though! Applied to the togreg branch of iio.git, initially pushed out as testing for the autobuilders to play with it. Thanks, Jonathan
Hi Marek, Am 14.04.2016 um 22:01 schrieb Marek Vasut: > 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 ? > since you found them it would be better if you handle them. Regards Stefan
On 04/18/2016 08:19 AM, Stefan Wahren wrote: > Hi Marek, > > Am 14.04.2016 um 22:01 schrieb Marek Vasut: >> 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 ? >> > > since you found them it would be better if you handle them. Roger. Since Atmel was so kind to provide sama5d2 and I also have sama5d4 board here, I will check the Atmel one at least.
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. > I suspect no platform is probing and removing it enough to get a significant > amount of memory leaked. > > Good to clear it up though! > > Applied to the togreg branch of iio.git, initially pushed out as testing for > the autobuilders to play with it. > > Thanks, > > Jonathan >
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. Stefan > >> I suspect no platform is probing and removing it enough to get a significant >> amount of memory leaked. >> >> Good to clear it up though! >> >> Applied to the togreg branch of iio.git, initially pushed out as testing for >> the autobuilders to play with it. >> >> Thanks, >> >> Jonathan >> >
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. This one? Why exactly? Please elaborate some more, so it's possible to understand the reasoning :)
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. > 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
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 >
On 04/19/2016 03:37 PM, 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. >> 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. I see, yes, it's not a memleak. > This commit also simplifies the code but in this case we should also > remove input_unregister_device. This matches the explanation in drivers/input/input.c above input_register_device() , agreed. > Regards > Stefan >
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)
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(-)