Patchwork [1/2] MTD: blkdevs: fix crash related to sysfs attributes.

login
register
mail settings
Submitter Maxim Levitsky
Date July 28, 2010, 3:53 p.m.
Message ID <1280332397-6031-2-git-send-email-maximlevitsky@gmail.com>
Download mbox | patch
Permalink /patch/60159/
State New
Headers show

Comments

Maxim Levitsky - July 28, 2010, 3:53 p.m.
Remove the attributes group before disk to avoid use after free

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/mtd/mtd_blkdevs.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 03e19c1..75aba70 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -409,13 +409,14 @@  int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
 		BUG();
 	}
 
-	/* Stop new requests to arrive */
-	del_gendisk(old->disk);
-
 	if (old->disk_attributes)
 		sysfs_remove_group(&disk_to_dev(old->disk)->kobj,
 						old->disk_attributes);
 
+	/* Stop new requests to arrive */
+	del_gendisk(old->disk);
+
+
 	/* Stop the thread */
 	kthread_stop(old->thread);