mtd: rawnand: fix double free in atmel_pmecc_create_user()

BugLink: https://bugs.launchpad.net/bugs/2101915

commit d8e4771f99c0400a1873235704b28bb803c83d17 upstream.

The "user" pointer was converted from being allocated with kzalloc() to
being allocated by devm_kzalloc().  Calling kfree(user) will lead to a
double free.

Fixes: 6d734f1bfc33 ("mtd: rawnand: atmel: Fix possible memory leak")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dd45c87782738715d5e7c167f8dabf0814a7394a linux-6.6.y)
[koichiroden: follow-up fix from v6.6.69]
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
Dan Carpenter
2025-03-11 08:51:19 +09:00
committed by Stefan Bader
parent 894f189128
commit b70a56ddec
+1 -3
View File
@@ -380,10 +380,8 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc,
user->delta = user->dmu + req->ecc.strength + 1;
gf_tables = atmel_pmecc_get_gf_tables(req);
if (IS_ERR(gf_tables)) {
kfree(user);
if (IS_ERR(gf_tables))
return ERR_CAST(gf_tables);
}
user->gf_tables = gf_tables;