Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753791AbbHaRRc (ORCPT ); Mon, 31 Aug 2015 13:17:32 -0400 Received: from mx-guillaumet.finsecur.com ([91.217.234.131]:33199 "EHLO guillaumet.finsecur.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753481AbbHaRRb (ORCPT ); Mon, 31 Aug 2015 13:17:31 -0400 From: Sylvain Rochet To: Mark Brown , Markus Pargmann , Kuninori Morimoto , Srinivas Kandagatla , Xiubo Li , Nicolas Boichat , Pankaj Dubey , linux-kernel@vger.kernel.org, Stephen Rothwell Cc: Sylvain Rochet Date: Mon, 31 Aug 2015 19:17:09 +0200 Message-Id: <1441041429-28749-1-git-send-email-sylvain.rochet@finsecur.com> X-Mailer: git-send-email 2.5.1 X-SA-Exim-Connect-IP: 172.16.8.13 X-SA-Exim-Mail-From: sylvain.rochet@finsecur.com Subject: [PATCH] regmap: fix NULL pointer dereference in __regmap_init if bus is NULL X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on guillaumet.finsecur.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1398 Lines: 35 This fix adds a check for bus pointer before using bus struct members. Signed-off-by: Sylvain Rochet --- drivers/base/regmap/regmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) It was introduced by https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=5e5a40ab02e497fd234a54c3fb6eb05286636e7a but I failed to find the commit which is not the merge commit. diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 650d3b1..7797cfd 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -574,8 +574,10 @@ struct regmap *__regmap_init(struct device *dev, map->use_single_read = config->use_single_rw || !bus || !bus->read; map->use_single_write = config->use_single_rw || !bus || !bus->write; map->can_multi_write = config->can_multi_write && bus && bus->write; - map->max_raw_read = bus->max_raw_read; - map->max_raw_write = bus->max_raw_write; + if (bus) { + map->max_raw_read = bus->max_raw_read; + map->max_raw_write = bus->max_raw_write; + } map->dev = dev; map->bus = bus; map->bus_context = bus_context; -- 2.5.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/