linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user()
@ 2024-10-23  8:40 Dan Carpenter
  2024-10-23  9:49 ` Miquel Raynal
  2024-12-05 10:43 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-10-23  8:40 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Alexandre Belloni, linux-kernel, Vignesh Raghavendra,
	Richard Weinberger, kernel-janitors, Claudiu Beznea, linux-mtd,
	linux-arm-kernel

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>
---
 drivers/mtd/nand/raw/atmel/pmecc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/atmel/pmecc.c b/drivers/mtd/nand/raw/atmel/pmecc.c
index a22aab4ed4e8..3c7dee1be21d 100644
--- a/drivers/mtd/nand/raw/atmel/pmecc.c
+++ b/drivers/mtd/nand/raw/atmel/pmecc.c
@@ -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;
 
-- 
2.45.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user()
  2024-10-23  8:40 [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user() Dan Carpenter
@ 2024-10-23  9:49 ` Miquel Raynal
  2024-12-05 10:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2024-10-23  9:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexandre Belloni, linux-kernel, Vignesh Raghavendra,
	Richard Weinberger, kernel-janitors, Claudiu Beznea, linux-mtd,
	linux-arm-kernel

Hi Dan,

dan.carpenter@linaro.org wrote on Wed, 23 Oct 2024 11:40:56 +0300:

> 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")

Hm, I missed it. Thanks for the fix!

Thanks,
Miquèl


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user()
  2024-10-23  8:40 [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user() Dan Carpenter
  2024-10-23  9:49 ` Miquel Raynal
@ 2024-12-05 10:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2024-12-05 10:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alexandre Belloni, linux-kernel, Vignesh Raghavendra,
	Richard Weinberger, kernel-janitors, Claudiu Beznea, linux-mtd,
	Miquel Raynal, linux-arm-kernel

On Wed, 23 Oct 2024 11:40:56 +0300, Dan Carpenter wrote:
> 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.
> 
> 

Applied to mtd/fixes, thanks!

[1/1] mtd: rawnand: fix double free in atmel_pmecc_create_user()

Patche(s) will be available within hours on:
mtd/linux.git

Kind regards,
Miquèl


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-05 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23  8:40 [PATCH next] mtd: rawnand: fix double free in atmel_pmecc_create_user() Dan Carpenter
2024-10-23  9:49 ` Miquel Raynal
2024-12-05 10:43 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).