From patchwork Sat Jul 1 03:45:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 106781 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3071966qge; Fri, 30 Jun 2017 20:47:43 -0700 (PDT) X-Received: by 10.84.195.131 with SMTP id j3mr27832047pld.147.1498880863436; Fri, 30 Jun 2017 20:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498880863; cv=none; d=google.com; s=arc-20160816; b=c9ib8OpG5F//B/dTT0ocadWhSYDGQ9HCuWEs132/UqKOCzgGGZg4u9a6zFR5XWbSrV DFETwAmDV8kVJGz6PDaxwb+aqZWToKp99z5NgIfYwUNSEZ/cWZoF5EYokqyoY4aOCVzM 1UKXH2NXWTYSsdmMrAbKtyemtPfc7WmBTcJEExzWcUNH8ZP2H8XdQygl+MjC2ZmHO5t/ UXn+TKjuCIL5nSBEWErcEZUaK6kLxhg5RgFKk7frDKEdIuJnXWHy2UdqsJcH/JmNOvAd oE6j1x32yMCfInhNUN8tVV0CF4cQFng4IW1u3Wj7uDHIEQjQ23n+1tYbx1ZW7zg6wqsf UGmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:arc-authentication-results; bh=ZH7wI8XLyEfgKyem7f+f3jpDuQHOQ0RlQ7Td+3bbrhk=; b=Suj9WbO6Kh0KgbIbjCy/nhpjVQvTM8J9s4RjesZpqIdjm8B3Lq0REF4X5JZ57LJc2I +OjLH2pMceMnQlTVzjnVHw453z8VMLOgtKKYT3GwDpn9s6NxZAatW1wQOrAa+vOigrtS uaNdlw+R4aOO6mu8kRK4NKa8rj9x50OJcaoASZ+3JguBilKRUHRyrs8xeTLTLfcVXNmb 4jRCIEICtqHkclgcxg7zDwoDyuaVAwSlcAzzPHn98eJ23qNn69niXc5QN8T/uoAhq5H/ XvcT/8nr1j2mQEAjgHVHdQyFMFgyI8AEnsk98+4YLoCdhiGDa4ogR6QhuiW7ZGkF/UG2 K5+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15si7595777plj.408.2017.06.30.20.47.42; Fri, 30 Jun 2017 20:47:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbdGADqI (ORCPT + 4 others); Fri, 30 Jun 2017 23:46:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:49564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751370AbdGADqH (ORCPT ); Fri, 30 Jun 2017 23:46:07 -0400 Received: from localhost.localdomain (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85ABA22BCE; Sat, 1 Jul 2017 03:46:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85ABA22BCE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org From: Shawn Guo To: Linus Walleij Cc: Dan Carpenter , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Shawn Guo Subject: [PATCH] pinctrl: zte: fix dereference of 'data' in zx_set_mux() Date: Sat, 1 Jul 2017 11:45:36 +0800 Message-Id: <1498880736-18143-1-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Shawn Guo It fixes the following Smatch complaint: drivers/pinctrl/zte/pinctrl-zx.c:76 zx_set_mux() warn: variable dereferenced before check 'data' (see line 67) Reported-by: Dan Carpenter Fixes: cbff0c4d27f4 ("pinctrl: add ZTE ZX pinctrl driver support") Signed-off-by: Shawn Guo --- drivers/pinctrl/zte/pinctrl-zx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pinctrl/zte/pinctrl-zx.c b/drivers/pinctrl/zte/pinctrl-zx.c index 787e3967bd5c..f828ee340a98 100644 --- a/drivers/pinctrl/zte/pinctrl-zx.c +++ b/drivers/pinctrl/zte/pinctrl-zx.c @@ -64,10 +64,8 @@ static int zx_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector, struct zx_pinctrl_soc_info *info = zpctl->info; const struct pinctrl_pin_desc *pindesc = info->pins + group_selector; struct zx_pin_data *data = pindesc->drv_data; - struct zx_mux_desc *mux = data->muxes; - u32 mask = (1 << data->width) - 1; - u32 offset = data->offset; - u32 bitpos = data->bitpos; + struct zx_mux_desc *mux; + u32 mask, offset, bitpos; struct function_desc *func; unsigned long flags; u32 val, mval; @@ -76,6 +74,11 @@ static int zx_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector, if (!data) return -EINVAL; + mux = data->muxes; + mask = (1 << data->width) - 1; + offset = data->offset; + bitpos = data->bitpos; + func = pinmux_generic_get_function(pctldev, func_selector); if (!func) return -EINVAL;