summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNavid Emamdoost <navid.emamdoost@gmail.com>2021-03-13 18:29:49 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-17 16:34:35 +0100
commit593b7ff46bc064f2acac9ed6b7baa3189d2bcd90 (patch)
tree2b05bbd46efdc009ebdde757baba057da2c70e4f
parentccb7c819942daaeda58978d26fb45a3a48c2f8f6 (diff)
downloadlinux-stable-593b7ff46bc064f2acac9ed6b7baa3189d2bcd90.tar.gz
linux-stable-593b7ff46bc064f2acac9ed6b7baa3189d2bcd90.tar.bz2
linux-stable-593b7ff46bc064f2acac9ed6b7baa3189d2bcd90.zip
iio: imu: adis16400: release allocated memory on failure
commit ab612b1daf415b62c58e130cb3d0f30b255a14d0 upstream. In adis_update_scan_mode, if allocation for adis->buffer fails, previously allocated adis->xfer needs to be released. 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> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 36607d52fee0..9de553e8c214 100644
--- a/drivers/iio/imu/adis_buffer.c
+++ b/drivers/iio/imu/adis_buffer.c
@@ -39,8 +39,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
return -ENOMEM;
adis->buffer = kzalloc(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;