Skip to content

Commit ab612b1

Browse files
Navidemjic23
authored andcommitted
iio: imu: adis16400: release allocated memory on failure
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>
1 parent dcb1092 commit ab612b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: drivers/iio/imu/adis_buffer.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
7878
return -ENOMEM;
7979

8080
adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL);
81-
if (!adis->buffer)
81+
if (!adis->buffer) {
82+
kfree(adis->xfer);
83+
adis->xfer = NULL;
8284
return -ENOMEM;
85+
}
8386

8487
rx = adis->buffer;
8588
tx = rx + scan_count;

0 commit comments

Comments
 (0)