Re: [PATCH v3 2/3] iio: accel: kionix-kx022a: Prevent memory leak and fix state

From: Jonathan Cameron

Date: Sun Sep 06 2026 - 17:36:49 EST


On Wed, 2 Sep 2026 11:49:05 +0300
Matti Vaittinen <matti.vaittinen@xxxxxxxxx> wrote:

> From: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
>
> The driver allocates memory for samples at buffer enable path. If regmap
> operation fails in the kx022a_fifo_enable() at the buffer enable path, the
> allocated memory is never freed. Furthermore, the state information and
> previous hardware configuration(s) aren't undone, potentially leaving
> WMI interrupts and buffers enabled, or driver state flags wrong.
>
> Free the memory and revert the hardware configuration and state flags on
> error path.
>
> Fixes: e7123a4dfcd7 ("iio: accel: kionix-kx022a: Refactor driver and add chip_info structure")
> Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
> Reviewed-by: Mehdi Djait <mehdi.djait@xxxxxxxxxxxxxxx>
Applied and marked for stable.