Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755899AbdDFMDu (ORCPT ); Thu, 6 Apr 2017 08:03:50 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35626 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755664AbdDFMC6 (ORCPT ); Thu, 6 Apr 2017 08:02:58 -0400 From: Dmitry Monakhov To: linux-kernel@vger.kernel.org Cc: darrick.wong@oracle.com, axboe@kernel.dk, tytso@mit.edu, jack@suse.cz, hch@infradead.org, Dmitry Monakhov Subject: [PATCH 2/5] block: protect bdevname from null pointer bdev Date: Thu, 6 Apr 2017 16:02:46 +0400 Message-Id: <1491480169-1889-3-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1491480169-1889-1-git-send-email-dmonakhov@openvz.org> References: <1491480169-1889-1-git-send-email-dmonakhov@openvz.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 659 Lines: 22 Some callers (usually error paths) call bdevname with null bdev. Signed-off-by: Dmitry Monakhov --- 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