diff options
author | Navid Emamdoost <navid.emamdoost@gmail.com> | 2019-09-19 17:56:35 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2019-10-09 20:11:27 +0200 |
commit | 9c0530e898f384c5d279bfcebd8bb17af1105873 (patch) | |
tree | 9e9c315fa3700add84a58c7bab6dc57a9b13ba91 | |
parent | iio: imu: adis16400: release allocated memory on failure (diff) | |
download | linux-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.c | 5 |
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); |