Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617907 > unrolled thread

[PATCH 2/5] block: protect bdevname from null pointer bdev

Started byDmitry Monakhov <dmonakhov@openvz.org>
First post2017-04-06 14:10 +0200
Last post2017-04-06 14:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/5] block: protect bdevname from null pointer bdev Dmitry Monakhov <dmonakhov@openvz.org> - 2017-04-06 14:10 +0200

#1617907 — [PATCH 2/5] block: protect bdevname from null pointer bdev

FromDmitry Monakhov <dmonakhov@openvz.org>
Date2017-04-06 14:10 +0200
Subject[PATCH 2/5] block: protect bdevname from null pointer bdev
Message-ID<tteoF-8jD-15@gated-at.bofh.it>
Some callers (usually error paths) call bdevname with null bdev.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 block/partition-generic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/block/partition-generic.c b/block/partition-generic.c
index 7afb990..284de18 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -46,6 +46,8 @@ char *disk_name(struct gendisk *hd, int partno, char *buf)
 
 const char *bdevname(struct block_device *bdev, char *buf)
 {
+	if (unlikely(!bdev))
+		return snprintf(buf, BDEVNAME_SIZE, "unknown-block(null)");
 	return disk_name(bdev->bd_disk, bdev->bd_part->partno, buf);
 }
 
-- 
2.9.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web