Skip to contentSkip to conversation

MTD: FTL layer: don't free input argument in add_mtd_blktrans_dev

PATCH In review Maxim Levitsky 2 participants 2 messages Jan 8, 2011 – Jan 18, 2011 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MTD: FTL layer: don't free input argument in add_mtd_blktrans_dev

This one liner patch fixes double free that will occur if add_mtd_blktrans_dev fails. On failure it free input argument, but all its users
also free it on error which is natural thing to do.
Thus don't free it.

All credit for finding that bug belongs to reporters of the bug in the android bugzilla
http://code.google.com/p/android/issues/detail?id=13761

---
 drivers/mtd/mtd_blkdevs.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/mtd/mtd_blkdevs.c +0 -1
index cb20c67..e0a2373 100644
@@ -413,7 +413,6 @@ error3:
 error2:
 	list_del(&new->list);
 error1:
-	kfree(new);
 	return ret;
 }
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · Maxim Levitsky

This one liner patch fixes double free that will occur if add_mtd_blktrans_dev fails. On failure it free input argument, but all its users
also free it on error which is natural thing to do.
Thus don't free it.

All credit for finding that bug belongs to reporters of the bug in the android bugzilla
http://code.google.com/p/android/issues/detail?id=13761

Signed-off-by, (off, not of). I'll fix this.

I'll change your subject line to:

mtd: mtd_blkdevs: fix double free on error path

a) We use "mtd:" prefix, not "MTD:".
b). mtd_blkdevs is not really an FTL layer, I think.
c). The subject line has to make it obvious whether this is a bugfix or something else - it makes life of people who look at commit messages ans search for stuff important stuff easier. Your subject line is technically correct, but not very helpful.

Anyway, picked to l2-mtd-2.6.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Битюцкий Артём)