[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20221112174955.2d1d294a@jic23-huawei>
Date: Sat, 12 Nov 2022 17:49:55 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Jagath Jog J <jagathjog1996@...il.com>
Cc: Dong Chenchen <dongchenchen2@...wei.com>, dan@...obertson.com,
lars@...afoo.de, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, yuehaibing@...wei.com
Subject: Re: [Patch] iio: accel: bma400: Fix memory leak in
bma400_get_steps_reg()
On Fri, 11 Nov 2022 23:12:32 +0530
Jagath Jog J <jagathjog1996@...il.com> wrote:
> On Thu, Nov 10, 2022 at 6:37 AM Dong Chenchen <dongchenchen2@...wei.com> wrote:
> >
> > When regmap_bulk_read() fails, it does not free steps_raw,
> > which will cause a memory leak issue, this patch fixes it.
> >
> > Fixes: d221de60eee3 ("iio: accel: bma400: Add separate channel for step counter")
> > Signed-off-by: Dong Chenchen <dongchenchen2@...wei.com>
>
> Reviewed-by: Jagath Jog J <jagathjog1996@...il.com>
>
> Thanks for catching this
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
>
> Regards,
> Jagath
>
> > ---
> > drivers/iio/accel/bma400_core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> > index ad8fce3e08cd..43976cf5a91b 100644
> > --- a/drivers/iio/accel/bma400_core.c
> > +++ b/drivers/iio/accel/bma400_core.c
> > @@ -805,8 +805,10 @@ static int bma400_get_steps_reg(struct bma400_data *data, int *val)
> >
> > ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG,
> > steps_raw, BMA400_STEP_RAW_LEN);
> > - if (ret)
> > + if (ret) {
> > + kfree(steps_raw);
> > return ret;
> > + }
> > *val = get_unaligned_le24(steps_raw);
> > kfree(steps_raw);
> > return IIO_VAL_INT;
> > --
> > 2.25.1
> >
Powered by blists - more mailing lists