Skip to content

Commit 9c0530e

Browse files
Navidemjic23
authored andcommitted
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>
1 parent ab612b1 commit 9c0530e

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
@@ -35,8 +35,11 @@ static int adis_update_scan_mode_burst(struct iio_dev *indio_dev,
3535
return -ENOMEM;
3636

3737
adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
38-
if (!adis->buffer)
38+
if (!adis->buffer) {
39+
kfree(adis->xfer);
40+
adis->xfer = NULL;
3941
return -ENOMEM;
42+
}
4043

4144
tx = adis->buffer + burst_length;
4245
tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);

0 commit comments

Comments
 (0)