Skip to content

Commit 20690cd

Browse files
Dong Chenchenjic23
authored andcommitted
iio: accel: bma400: Fix memory leak in bma400_get_steps_reg()
When regmap_bulk_read() fails, it does not free steps_raw, which will cause a memory leak issue, this patch fixes it. Fixes: d221de6 ("iio: accel: bma400: Add separate channel for step counter") Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com> Reviewed-by: Jagath Jog J <jagathjog1996@gmail.com> Link: https://lore.kernel.org/r/20221110010726.235601-1-dongchenchen2@huawei.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 6ac1230 commit 20690cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/iio/accel/bma400_core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,10 @@ static int bma400_get_steps_reg(struct bma400_data *data, int *val)
805805

806806
ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG,
807807
steps_raw, BMA400_STEP_RAW_LEN);
808-
if (ret)
808+
if (ret) {
809+
kfree(steps_raw);
809810
return ret;
811+
}
810812
*val = get_unaligned_le24(steps_raw);
811813
kfree(steps_raw);
812814
return IIO_VAL_INT;

0 commit comments

Comments
 (0)