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 <[email protected]> Reviewed-by: Alexandru Ardelean <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent dcb1092 commit ab612b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/iio/imu/adis_buffer.c

Lines changed: 4 additions & 1 deletion
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)