From: Christoph Hellwig Date: Thu, 14 Oct 2021 13:02:31 +0000 (+0200) Subject: block: warn when putting the final reference on a registered disk X-Git-Tag: baikal/mips/sdk5.9~9867^2~1 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=02955950cc8324ec9e687c1c1b968badca1580e5;p=kernel.git block: warn when putting the final reference on a registered disk Warn when the last reference on a live disk is put without calling del_gendisk first. There are some BDI related bug reports that look like a case of this, so make sure we have the proper instrumentation to catch it. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20211014130231.1468538-1-hch@lst.de Signed-off-by: Jens Axboe --- diff --git a/block/genhd.c b/block/genhd.c index 7a766cc613c76..b49858550fa6e 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -1078,6 +1078,7 @@ static void disk_release(struct device *dev) struct gendisk *disk = dev_to_disk(dev); might_sleep(); + WARN_ON_ONCE(disk_live(disk)); disk_release_events(disk); kfree(disk->random);