Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751396Ab3IJKh5 (ORCPT ); Tue, 10 Sep 2013 06:37:57 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:26610 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751206Ab3IJKh4 (ORCPT ); Tue, 10 Sep 2013 06:37:56 -0400 From: Vaughan Cao To: axboe@kernel.dk, linux-kernel@vger.kernel.org Cc: vaughan.cao@oracle.com Subject: [PATCH] block: register_blkdev doesn't check name against NULL Date: Tue, 10 Sep 2013 18:40:14 +0800 Message-Id: <1378809614-17490-1-git-send-email-vaughan.cao@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 840 Lines: 30 register_blkdev(0, NULL) can result kernel Oops by copying from NULL in strlcpy(). Fix it by checking NULL pointer at the beginning. Signed-off-by: Vaughan Cao --- block/genhd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index dadf42b..9564f19 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -287,6 +287,9 @@ int register_blkdev(unsigned int major, const char *name) struct blk_major_name **n, *p; int index, ret = 0; + if (!name) + return -EINVAL; + mutex_lock(&block_class_lock); /* temporary */ -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/