[PATCH] Fix refcounting bug in the block core

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
This patch (as900) fixes some driver-core bogosity recently introduced
into the gendisk driver by Kay's block-device.patch.

Shame, shame...  :-)

Signed-off-by: Alan Stern <[email protected]>

---

Index: usb-2.6/fs/partitions/check.c
===================================================================
--- usb-2.6.orig/fs/partitions/check.c
+++ usb-2.6/fs/partitions/check.c
@@ -377,12 +377,20 @@ static int disk_sysfs_symlinks(struct ge
 
 	err = sysfs_create_link(&block_depr, &disk->dev.kobj,
 				disk->dev.kobj.name);
-	if (err && target)
+	if (err)
 		put_device(target);
 #endif
 	return err;
 }
 
+static void disk_sysfs_remove_symlinks(struct gendisk *disk)
+{
+#ifdef CONFIG_SYSFS_DEPRECATED_FUTURE
+	sysfs_remove_link(&block_depr, disk->dev.kobj.name);
+	put_device(disk->dev.parent);
+#endif
+}
+
 /* Not exported, helper to add_disk(). */
 void register_disk(struct gendisk *disk)
 {
@@ -525,13 +533,7 @@ void del_gendisk(struct gendisk *disk)
 
 	kobject_unregister(disk->holder_dir);
 	kobject_unregister(disk->slave_dir);
-	if (disk->driverfs_dev) {
-		put_device(disk->dev.parent);
-		disk->dev.parent = NULL;
-		disk->driverfs_dev = NULL;
-	}
-#ifdef CONFIG_SYSFS_DEPRECATED_FUTURE
-	sysfs_remove_link(&block_depr, disk->dev.bus_id);
-#endif
+
+	disk_sysfs_remove_symlinks(disk);
 	device_del(&disk->dev);
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.