mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zdenek.kabelac@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH] Make a basic error check for failure in register_disk()
Date: Tue, 22 Sep 2009 13:51:22 +0200	[thread overview]
Message-ID: <c4e36d110909220451s5c58a10esc00c1c1d01f6c3a4@mail.gmail.com> (raw)

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;

                 reply	other threads:[~2009-09-22 11:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4e36d110909220451s5c58a10esc00c1c1d01f6c3a4@mail.gmail.com \
    --to=zdenek.kabelac@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®