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

From: Matti Vaittinen

Date: Sun Aug 30 2026 - 05:34:04 EST


On 30/08/2026 04:22, Jonathan Cameron wrote:
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>

I'm not happy with the label naming. It had me very confused!

Hmm. I suppose it could be more consistent :) Thanks.

Yours,
-- Matti


--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~