From patchwork Fri Aug 4 02:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 797567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="VVfVqu7P"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xNs9K5k2mz9s7C for ; Fri, 4 Aug 2017 13:00:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751891AbdHDDAE (ORCPT ); Thu, 3 Aug 2017 23:00:04 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:21640 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbdHDDAD (ORCPT ); Thu, 3 Aug 2017 23:00:03 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id v742xiZ8005507; Fri, 4 Aug 2017 11:59:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com v742xiZ8005507 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1501815584; bh=UcdOk7OugVWaRpX6vUIuwEhGb5iMInI/+K9MbeqrSEM=; h=From:To:Cc:Subject:Date:From; b=VVfVqu7Pl88XEfgEvC4RGlu16e9y71F9Tt2EweB3zq2fgZfSAEnAK7vdZ0fOIThZQ fjbtDa3uRnKQJ2w38QqrQou+i86m/LtxGyH7N+2xraRTSTQm8sJcI9M1q9B2PweaGB DOTSv3GjiIXMEuIg3NqFRKh4QC2wPDUbxjP26GppTNqEB3f7wdBIjKpi5r9TUPQ6Pv 8KqEvN9YWt4VVPzZTAeklegM4KjCD4Oharf2mLJhjCXb3bcR09cBi+SiCoDOrcCe8v ZMQAmJ0jN4CtXZF0xKr2oZrMpJ2H49aiA2PJsudqH9tFIJvNMFQGyiJ3CH3mYwhoeV SFFA2oa3nzJZQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-gpio@vger.kernel.org Cc: Andy Shevchenko , Mika Westerberg , Masahiro Yamada , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH] pinctrl: check ops->pin_config_set in pinconf_set_config() Date: Fri, 4 Aug 2017 11:59:32 +0900 Message-Id: <1501815572-2792-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org pinconf_set_config() is called by pinctrl_gpio_set_config(). If a GPIO driver is backed by a pinctrl driver and it does not support .pin_config_set() hook, it causes NULL pointer dereference. Fixes: 15381bc7c7f5 ("pinctrl: Allow configuration of pins from gpiolib based drivers") Signed-off-by: Masahiro Yamada Acked-by: Mika Westerberg --- drivers/pinctrl/pinconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 92f363793f35..d3fe14394b73 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c @@ -205,7 +205,7 @@ int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin, const struct pinconf_ops *ops; ops = pctldev->desc->confops; - if (!ops) + if (!ops || !ops->pin_config_set) return -ENOTSUPP; return ops->pin_config_set(pctldev, pin, configs, nconfigs);