Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751179AbbKIGXj (ORCPT ); Mon, 9 Nov 2015 01:23:39 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36297 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750738AbbKIGXh (ORCPT ); Mon, 9 Nov 2015 01:23:37 -0500 From: Saurabh Sengar To: andy.shevchenko@gmail.com Cc: joern@lazybastard.org, dwmw2@infradead.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Saurabh Sengar Subject: [PATCH v2] mtd: phram: error handling Date: Mon, 9 Nov 2015 11:53:18 +0530 Message-Id: <1447050198-20562-1-git-send-email-saurabh.truth@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1192 Lines: 36 registering the device with NULL pointer can lead to crash, hence fixing it Signed-off-by: Saurabh Sengar --- > Andy Shevchenko wrote: > Hmm… Why not just checking it before an register attempt? I think user > is in right to know as many problems as they have at one shot, with > your patch if there are two problems the user has to try twice. Yes, taken your feedback, fixing it here in v2 as you recommended drivers/mtd/devices/phram.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 8b66e52..46b7a8a 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -257,6 +257,9 @@ static int phram_setup(const char *val) parse_err("illegal device length\n"); } + if(!name) + return -EINVAL; + ret = register_device(name, start, len); if (!ret) pr_info("%s device: %#llx at %#llx\n", name, len, start); -- 1.9.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/