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


Groups > linux.kernel > #1617907

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

From Dmitry Monakhov <dmonakhov@openvz.org>
Newsgroups linux.kernel
Subject [PATCH 2/5] block: protect bdevname from null pointer bdev
Date 2017-04-06 14:10 +0200
Message-ID <tteoF-8jD-15@gated-at.bofh.it> (permalink)
References <tteoF-8jD-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web