]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mtd: rawnand: atmel: Fix possible memory leak
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 1 Oct 2024 20:31:49 +0000 (22:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 09:59:34 +0000 (10:59 +0100)
commit2014fcea19ec27df033359a0f42db0e8ed4290a8
tree99407c391f7edc22f7c7894110611af897225ff5
parent945aa077e3b8a7eaa858e2872618890ca6cac67e
mtd: rawnand: atmel: Fix possible memory leak

[ Upstream commit 6d734f1bfc336aaea91313a5632f2f197608fadd ]

The pmecc "user" structure is allocated in atmel_pmecc_create_user() and
was supposed to be freed with atmel_pmecc_destroy_user(), but this other
helper is never called. One solution would be to find the proper
location to call the destructor, but the trend today is to switch to
device managed allocations, which in this case fits pretty well.

Replace kzalloc() by devm_kzalloc() and drop the destructor entirely.

Reported-by: "Dr. David Alan Gilbert" <linux@treblig.org>
Closes: https://lore.kernel.org/all/ZvmIvRJCf6VhHvpo@gallifrey/
Fixes: f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20241001203149.387655-1-miquel.raynal@bootlin.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/nand/raw/atmel/pmecc.c
drivers/mtd/nand/raw/atmel/pmecc.h