[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150427151931.7a43ecc6@notabene.brown>
Date: Mon, 27 Apr 2015 15:19:31 +1000
From: NeilBrown <neilb@...e.de>
To: Jens Axboe <axboe@...com>, Tejun Heo <tj@...nel.org>
Cc: Christoph Hellwig <hch@....de>, lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH] block: turn Oops into WARNING if bdi_register_dev fails.
add_disk() does not return an error status, but it can
still fail if there are problems elsewhere.
In particular a recent problem caused bdi_register_dev()
to sometimes fail because the name was already in use.
In that case bdi->dev is NULL, so
retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj,
"bdi");
triggers an oops, after having already produced warnings.
This patch causes add_disk() to WARN and return if
bdi_register_dev() fails, much like it already does if
blk_alloc_devt() fails.
This should make no difference on a correctly functioning system, but
can make a developers life a bit easier.
Signed-off-by: NeilBrown <neilb@...e.de>
diff --git a/block/genhd.c b/block/genhd.c
index 0a536dc05f3b..e351fc521053 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -612,6 +612,10 @@ void add_disk(struct gendisk *disk)
/* Register BDI before referencing it from bdev */
bdi = &disk->queue->backing_dev_info;
bdi_register_dev(bdi, disk_devt(disk));
+ if (!bdi->dev) {
+ WARN_ON(1);
+ return;
+ }
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists