Skip to contentSkip to conversation

Add missing del_gendisk to error path

PATCH In review Zdenek Kabelac 2 participants 2 messages Sep 23, 2009 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add missing del_gendisk to error path

Add missing del_gendisk() to error path when creation of workqueue fails. Otherwice there is a resource leak and following warning is shown:

WARNING: at fs/sysfs/dir.c:487 sysfs_add_one+0xc5/0x160()

sysfs: cannot create duplicate filename '/devices/virtual/block/dm-0'

---
 drivers/md/dm.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/md/dm.c +1 -0
index b4845b1..bf5961d 100644
@@ -1819,6 +1819,7 @@ static struct mapped_device *alloc_dev(int minor)
 bad_bdev:
 	destroy_workqueue(md->wq);
 bad_thread:
+	del_gendisk(md->disk);
 	put_disk(md->disk);
 bad_disk:
 	blk_cleanup_queue(md->queue);
Reviewed-by on v1 1/1
#1 lore raw

brassow

Quoted 30 lines · Zdenek Kabelac

Add missing del_gendisk() to error path when creation of workqueue fails. Otherwice there is a resource leak and following warning is shown:

WARNING: at fs/sysfs/dir.c:487 sysfs_add_one+0xc5/0x160()

sysfs: cannot create duplicate filename '/devices/virtual/block/dm-0'

---
drivers/md/dm.c | 1 +

1 files changed, 1 insertions(+), 0 deletions(-)
drivers/md/dm.c +0 -0
index b4845b1..bf5961d 100644
@@ -1819,6 +1819,7 @@ static struct mapped_device *alloc_dev(int  
 minor)

bad_bdev:

	destroy_workqueue(md->wq);

bad_thread:

drivers/md/dm.c +1 -0
+	del_gendisk(md->disk);
	put_disk(md->disk);
bad_disk:
	blk_cleanup_queue(md->queue);

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel