Skip to content
Snippets Groups Projects
Commit 369f0568 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Jonathan Cameron
Browse files

iio: gts-helper: Fix memory leaks for the error path of iio_gts_build_avail_scale_table()


If per_time_scales[i] or per_time_gains[i] kcalloc fails in the for loop
of iio_gts_build_avail_scale_table(), the err_free_out will fail to call
kfree() each time when i is reduced to 0, so all the per_time_scales[0]
and per_time_gains[0] will not be freed, which will cause memory leaks.

Fix it by checking if i >= 0.

Cc: stable@vger.kernel.org
Fixes: 38416c28 ("iio: light: Add gain-time-scale helpers")
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Link: https://patch.msgid.link/20241016012453.2013302-1-ruanjinjie@huawei.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 691e79ff
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment