Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752020AbdGGVqU (ORCPT ); Fri, 7 Jul 2017 17:46:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:58196 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750726AbdGGVqT (ORCPT ); Fri, 7 Jul 2017 17:46:19 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,325,1496127600"; d="scan'208";a="108827996" From: sathyanarayanan.kuppuswamy@linux.intel.com To: peda@axentia.se Cc: linux-kernel@vger.kernel.org, sathyaosid@gmail.com, Kuppuswamy Sathyanarayanan Subject: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node Date: Fri, 7 Jul 2017 14:46:02 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 851 Lines: 30 From: Kuppuswamy Sathyanarayanan If dev->of_node is NULL, then calling mux_control_get() function can lead to NULL pointer exception. So adding a NULL check for dev->of_node. Signed-off-by: Kuppuswamy Sathyanarayanan --- drivers/mux/mux-core.c | 3 +++ 1 file changed, 3 insertions(+) Changes since v1: * Removed dummy new line. diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c index 90b8995..924c983 100644 --- a/drivers/mux/mux-core.c +++ b/drivers/mux/mux-core.c @@ -438,6 +438,9 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name) int index = 0; int ret; + if (!np) + return ERR_PTR(-ENODEV); + if (mux_name) { index = of_property_match_string(np, "mux-control-names", mux_name); -- 2.7.4