summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNavid Emamdoost <navid.emamdoost@gmail.com>2019-09-19 17:56:35 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-10-09 20:11:27 +0200
commit9c0530e898f384c5d279bfcebd8bb17af1105873 (patch)
tree9e9c315fa3700add84a58c7bab6dc57a9b13ba91
parentiio: imu: adis16400: release allocated memory on failure (diff)
downloadlinux-9c0530e898f384c5d279bfcebd8bb17af1105873.tar.xz
linux-9c0530e898f384c5d279bfcebd8bb17af1105873.zip
iio: imu: adis16400: fix memory leak
In adis_update_scan_mode_burst, if adis->buffer allocation fails release the adis->xfer. Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/imu/adis_buffer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
index f446ff497809..4998a89d083d 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -35,8 +35,11 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
return -ENOMEM;
adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
- if (!adis->buffer)
+ if (!adis->buffer) {
+ kfree(adis->xfer);
+ adis->xfer = NULL;
return -ENOMEM;
+ }
tx = adis->buffer + burst_length;
tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);