lkml.org 
[lkml]   [2026]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iio: adc: meson-saradc: fix calibration buffer leak on error
On Sat, 25 Apr 2026 11:17:18 -0500
David Lechner <dlechner@baylibre.com> wrote:

> On 4/25/26 11:07 AM, Felix Gu wrote:
> > meson_sar_adc_temp_sensor_init() allocates a buffer with
> > nvmem_cell_read(), but the old code leaked it if
> > syscon_regmap_lookup_by_phandle() failed.
> >
> > Switch buf to __free(kfree) so all return paths release it.
> >
> > Fixes: d6f2eac64403 ("iio: adc: meson: no devm for nvmem_cell_get")
> > Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> > ---
> > drivers/iio/adc/meson_saradc.c | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> > index 23991a3612bd..9708ddcc4919 100644
> > --- a/drivers/iio/adc/meson_saradc.c
> > +++ b/drivers/iio/adc/meson_saradc.c
> > @@ -786,7 +786,7 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev,
> > static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
> > {
>
> Nice to see one of these cleanup.h patches that is actually fixing a bug.

It's not fixing anything as far as I can see.
The syscon_regmap_lookup_by_handle() is earlier in the function and
nvmem_cell_read() isn't called if that fails.

So this is just a code simplification and so small benefit if anything.

Maybe there is an old version that does things in a different order?


>
> Should `#include <linux/cleanup.h>` though rather that relying on it being
> included through another header.
>
> With that fixed...
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
>


\
 
 \ /
  Last update: 2026-04-25 20:44    [W:0.100 / U:6.015 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog