Re: [PATCH] regmap-irq: Add missing kfree()

From: Matti Vaittinen
Date: Tue Feb 04 2025 - 03:34:24 EST


Thanks Jiang!

On 02/02/2025 22:05, Jiasheng Jiang wrote:
Add kfree() for "d->main_status_buf" in the error-handling path to prevent
a memory leak.

Fixes: a2d21848d921 ("regmap: regmap-irq: Add main status register support")
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@xxxxxxxxx>

This looks valid to me.

I still wonder if you could fix also the missing freeing from the regmap_del_irq_chip()? (AFAICS, the freeing is missing from that as well).

---
drivers/base/regmap/regmap-irq.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 0bcd81389a29..b73ab3cda781 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -906,6 +906,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
kfree(d->wake_buf);
kfree(d->mask_buf_def);
kfree(d->mask_buf);
+ kfree(d->main_status_buf);
kfree(d->status_buf);
kfree(d->status_reg_buf);
if (d->config_buf) {