mtd: blkdevs: fix crash related to sysfs attributes.

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Aug 6 04:59:01 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=dba76c033f1b88b6eb0fa697b824f954b11f8a97
Commit:     dba76c033f1b88b6eb0fa697b824f954b11f8a97
Parent:     ef41e1bb11fc21acad35c8c3b673fe9f2f29d819
Author:     Maxim Levitsky <maximlevitsky at gmail.com>
AuthorDate: Wed Jul 28 18:53:16 2010 +0300
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Aug 6 09:20:47 2010 +0100

    mtd: blkdevs: fix crash related to sysfs attributes.
    
    Remove the attributes group before disk to avoid use after free
    
    Signed-off-by: Maxim Levitsky <maximlevitsky at gmail.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtd_blkdevs.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index a6bb586..89e07e5 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -410,13 +410,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);
 



More information about the linux-mtd-cvs mailing list