lkml.org 
[lkml]   [2009]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH] Make a basic error check for failure in register_disk()
From
Make a basic error check for failure in register_disk() to avoid kernel BUG
when sysfs entry could not be created (i.e. duplicate filename).
Fix is not perfect as register_disk() and add_disk() should probably return
error code in this case but avoids this BUG message:

kernel BUG at fs/sysfs/group.c:65!
[<ffffffff812d6eac>] ? device_add+0x3c/0x5a0
[<ffffffff811767c3>] sysfs_create_group+0x13/0x20
[<ffffffff810c6c14>] blk_trace_init_sysfs+0x14/0x20
[<ffffffff8121e3b0>] blk_register_queue+0x40/0x100
[<ffffffff81223438>] add_disk+0xf8/0x170
[<ffffffffa00bb3aa>] dm_create+0x37a/0x5b0 [dm_mod]
...

Problem has been noticed during check of some dm error code path.

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>

---
block/genhd.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index f4c64c2..317f961 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -544,6 +544,10 @@ void add_disk(struct gendisk *disk)
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
register_disk(disk);
+ if (!disk_to_dev(disk)->kobj.parent) {
+ WARN_ON(1);
+ return;
+ }
blk_register_queue(disk);

bdi = &disk->queue->backing_dev_info;

\
 
 \ /
  Last update: 2009-09-22 13:53    [W:4.673 / U:0.420 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site