lkml.org 
[lkml]   [2019]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2] iio: imu: adis16400: release allocated memory on failure
On Fri, 20 Sep 2019 06:46:37 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Thu, 2019-09-19 at 10:50 -0500, Navid Emamdoost wrote:
> > In adis_update_scan_mode, if allocation for adis->buffer fails,
> > previously allocated adis->xfer needs to be released.
> >
> > v2: added adis->xfer = NULL to avoid any potential double free.

Version changes go below the --- so they don't get recorded in the
git tree log when it's applied.


>
> Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied to the fixes-togreg branch of iio.git. Thanks,

Jonathan

>
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> > drivers/iio/imu/adis_buffer.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/imu/adis_buffer.c
> > b/drivers/iio/imu/adis_buffer.c
> > index 9ac8356d9a95..f446ff497809 100644
> > --- a/drivers/iio/imu/adis_buffer.c
> > +++ b/drivers/iio/imu/adis_buffer.c
> > @@ -78,8 +78,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
> > return -ENOMEM;
> >
> > adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL);
> > - if (!adis->buffer)
> > + if (!adis->buffer) {
> > + kfree(adis->xfer);
> > + adis->xfer = NULL;
> > return -ENOMEM;
> > + }
> >
> > rx = adis->buffer;
> > tx = rx + scan_count;

\
 
 \ /
  Last update: 2019-09-21 20:12    [W:0.048 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site