From patchwork Tue May 25 16:55:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 447337 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp4451600jac; Tue, 25 May 2021 09:55:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw96aqYp3UJL8dcVtg/A71oEgoYjJr4/lYTQNj4WvSSwlCD3C+rvtQRx5P/NkzqH0KciaHy X-Received: by 2002:a05:6402:34d5:: with SMTP id w21mr33028955edc.38.1621961755980; Tue, 25 May 2021 09:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621961755; cv=none; d=google.com; s=arc-20160816; b=prIwpEwW7SQQHGHhByrUKdD7qBXfOp/mU7LxRXV0KfsqT43SPhGXBixGdkUhBCvlhN CxJ1D//FkzZ8gYEkieRUq7QDVnid9Xq5UaMd9/OdOnFrbMNG2VQdLet+2ZVCY/ZGsQXp R0Y0rtn4KvKeIpUvfS8Z5nZL3XhN/2epA5ISxP1FMSdAs/aneckixj1pCmTJju+Dj6e4 pL22Lw5ZHe5WpZyUGxm8oZ2Ku63Rtb4qcWH163jiuNo+QofRzqTzVuioE0kwQGj/bPcq ZSs8Drgne4MCC2HRiVSshpZ5Waj88UYm5vs4eNACRyrYvxJlqRH4wcv37oHLTTnJrS0L e31w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=56nDPhFIj8bYnpdmgf2D5pufG3atbZiNiJawhVqj3ks=; b=dW4owU0V8i0Z+Dpj2ySoC4oO2RdoQ3PXrvhuWqwXiZ6W2w/tvd0N4j5/uoVn4PyMMV Wh3VVo58y8seVhb013bitGHnO8W4k9UabuvDb1ChYjPh8jOHIj+xHKmCrpyeyFHHps0H OQcbda+ek1tLoYavA4H5lnV1qOXX7L6QJ/oyML8xuqQxO9MSbxymMe2SJMac86MH5yQu f13ao+lTzkli6DjyOrbykbs7dQA3HZ0u7YKk985KnS+9KNJhIDdt6g0it/TtnJdLL787 b4t3SguykvHZyCPWPleo0Kq9AZn6EXfF0WdnAOswtG4BQMKKfKb7QRO3zxZGhPH8jtJA Hs0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCjBiw1k; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kt7si15811670ejb.630.2021.05.25.09.55.55; Tue, 25 May 2021 09:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCjBiw1k; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhEYQ5W (ORCPT + 3 others); Tue, 25 May 2021 12:57:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232245AbhEYQ5V (ORCPT ); Tue, 25 May 2021 12:57:21 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F5BC061756 for ; Tue, 25 May 2021 09:55:50 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id y14so30902505wrm.13 for ; Tue, 25 May 2021 09:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=56nDPhFIj8bYnpdmgf2D5pufG3atbZiNiJawhVqj3ks=; b=bCjBiw1k+xFMqPf4nex6kscsLYlhaIHMRIYgmoLAPAYShq9qTUzpF3W5fPN+obY8Wc vtsguGfPBszH7fOHD+387HersGfn3O2yVc+emyPzERdGXK8zQTp26lI2Xd25+KzMc6gm QR9NAUJ2uX0Bk0AJDArhg2TKp7lL4tHFSvv1BMHSzNkEzOQqcWGu5EkB/Y8W7yOWmb0S sIBylF0934BiTKctU9EmPhSnbl+vuED5mG6lxF2L9dKN7/UUyZfxhRo9bhIUj1rxAbw8 7+HvMcr7+cbQG8cBjt0MC8aKvOY7htL9P8VeqIsAwLCbws69uC0qW88wG40Q0a7ITM/p tfsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=56nDPhFIj8bYnpdmgf2D5pufG3atbZiNiJawhVqj3ks=; b=O4iq04rddavNDjLFuv52OczRTsojNFV/xMrjziOEamLjjAmMK9CRkMusggLM66Fmhn cPwuC+J9a9viG16GDUODlQv/EA+ATWmfPml2MLJMpQJRceNO5ZhxtP3F9tFyj94kJ5q+ Jswl6kDg9A4P7Ew3IhISY2GhoyfcVOM0WPNld7dzUE2BUERHvmsrQLq4PxFfrrSyTztL AxWd1avJUoVoK963YVtNcfmwTQlJPooBjhYabF/XiIb37ZkHTJV1jYRtW7hm48ziCP4/ 7HwHI1LqByIpHVImuv65AyF4QLEWUWMfpgZbE7SRP4EPlyyi/oP1dwgT4QVfJlKnVe70 PqXg== X-Gm-Message-State: AOAM531h78f6hgrjXUTP59qq1UGK7Lfr5d39Pc2BDOkm4PXLCjyp1AtG 1i0N9117nc77d/FPy2UgyxlZ1g== X-Received: by 2002:a5d:650b:: with SMTP id x11mr27794223wru.186.1621961748918; Tue, 25 May 2021 09:55:48 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id l3sm11571447wmh.2.2021.05.25.09.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 09:55:48 -0700 (PDT) From: Srinivas Kandagatla To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, john.stultz@linaro.org, amit.pundir@linaro.org, bjorn.andersson@linaro.org, andy.shevchenko@gmail.com, Srinivas Kandagatla Subject: [RESEND PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error Date: Tue, 25 May 2021 17:55:39 +0100 Message-Id: <20210525165539.25330-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org bit-mask for pins 0 to 4 is BIT(0) to BIT(4) however we ended up with BIT(n - 1) which is not right, and this was caught by below usban check UBSAN: shift-out-of-bounds in drivers/gpio/gpio-wcd934x.c:34:14 Fixes: 59c324683400 ("gpio: wcd934x: Add support to wcd934x gpio controller") Signed-off-by: Srinivas Kandagatla Reviewed-by: Andy Shevchenko Reviewed-by: Bjorn Andersson --- changes since v1: - removed unnecessary dump stack from log drivers/gpio/gpio-wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c index 1cbce5990855..97e6caedf1f3 100644 --- a/drivers/gpio/gpio-wcd934x.c +++ b/drivers/gpio/gpio-wcd934x.c @@ -7,7 +7,7 @@ #include #include -#define WCD_PIN_MASK(p) BIT(p - 1) +#define WCD_PIN_MASK(p) BIT(p) #define WCD_REG_DIR_CTL_OFFSET 0x42 #define WCD_REG_VAL_CTL_OFFSET 0x43 #define WCD934X_NPINS 5