From patchwork Wed Mar 10 17:43:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 396771 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp572579jai; Wed, 10 Mar 2021 09:44:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyt0pIue3U8j9c9q57PI9Bap2r/GEnVpTKLfrPv3oW27kiCsPuUHPLKD31lB7YilSvtVOY X-Received: by 2002:a05:6402:b21:: with SMTP id bo1mr4551706edb.368.1615398262696; Wed, 10 Mar 2021 09:44:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615398262; cv=none; d=google.com; s=arc-20160816; b=ZHyZ8xRAXytPo9smXIXeYmEtE3ltVCG6Eat1nDtcTn6K5HZYnXYTdsEBbZJZVpRuVc l2PZAzA/q31x6n7Sl34xi5NhmsLYVKRTXTnDJLayD+GOxnmsRYMJ3rmmOWEVbcoWXNbG SaqDsHjv1W3vaQh7AT6BwvAte97/ZZUTpctU+CZCNot4FUYcfEmuRdd0toN9vOCtJY3Z NzX593JSoeYP/4ArDJM1esKVANE49DlH7UsYP29eXoW/GXXjsEBi3YHTX0n71YAa9jXB GVGTomeri+2ZYJ+nLW427SsO0+1pomt5pti4vGqLrmKPD8omEqocdPAd9BEGIenVp6sg G3sg== 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=QVRp3XgdEf96v7bzdf/9udqO1z6/YKzarZhSzPUl2Ao=; b=HGUxqOrSruCofNYcWN/qhHgqtVl9nT3ncwNv/7vx/lhozbY+YHyhD5/pyoi9nIdYOd Q97MYhp8CcXdWmn2P0CJZcDZFTcbEZRcMfFpr95NzdupGxOOGh1kEUquobtQRM2I49sF U+tTZ5V8CT2Dc+p8m25hfon27tk4HpBjaV1r+jA2bWFjivnYHM3TpD3oWh4HZ/cMx2Z5 mICd7otxSBo2uoyiEz/U42pnpV47bU7wYmQjhD+rfMJA5baxdxCJbFkwWx5hd7AW/y86 Kju6QoQlcLr/L8taaBIzSwJp+NHO0TgyEg5itszocEqWgQlb/14VKz7f0mO78G0D3mBa Ha5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qQNgkKka; 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 by17si26618ejc.260.2021.03.10.09.44.22; Wed, 10 Mar 2021 09:44:22 -0800 (PST) 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=qQNgkKka; 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 S232065AbhCJRns (ORCPT + 3 others); Wed, 10 Mar 2021 12:43:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbhCJRnS (ORCPT ); Wed, 10 Mar 2021 12:43:18 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A0A2C061760 for ; Wed, 10 Mar 2021 09:43:18 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo11248494wmq.4 for ; Wed, 10 Mar 2021 09:43:18 -0800 (PST) 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=QVRp3XgdEf96v7bzdf/9udqO1z6/YKzarZhSzPUl2Ao=; b=qQNgkKkaoVuUb8svFTJfxDaCJw+KYrPfZ4DjT5xDAeg6PDddio33O0CtuYm6nTYR4y cSCCXEmy3S32fkBMfB/hFoJv1Bqt53M6NyOBMWF+8iFEf8Na8T7rXZ7FjdsfkwOGSDih jkjX2968pOr5lSbyFAMg0eMti6gE51hbQxx6ewxOMu67bxvU1Ouc8JFgbZsOeA6bw9QB XX9aNBhUeUkJuF7l06dtLz15DIGADdgq47TNXfFt1DM2kHcJuWn+rKmxjjRY0IhELP1M OWxsTMBu8J5VxfmrGdpAH7Hlr61AZaseHBrdWLFdE9dtVgX3hvL0zAn27YLT7+6hrThK XwEw== 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=QVRp3XgdEf96v7bzdf/9udqO1z6/YKzarZhSzPUl2Ao=; b=LDPVIzxJgFNiLXbZkfSuZEaAxeVXixDKWBFLD6PMgQZaGPCcHX4JE8DydxxZjhxdVG 6U88w6pKHyVcaPeRYWVtW6VAMi8yH8WreuDqp/Kysw4ER9HHujzSiT2m6OzQUFrg9q7Y 1SDrfrX8yh5xeplEpkzUIzmbsNwHfl58aY8zR34fQWjcimhqUOgUlPJs2GwFpIeuTkNg 2rt4rcbtNcG5HLLk/+RToSz4ZfP1mYNu9kzJ7fJlmAZVkqf1mxepGcEc8t7YdcxmVIs4 qt3bjHIgJsvHtNeFCC8wO5ZiDeG78Yf52jqbQ2p3CXmlAGtOuinGfR5lem6usJS1b2IZ RzSA== X-Gm-Message-State: AOAM533JwRU9aSSoCfQkmFplg/FxDnS2NZMmqIC70Oqdh34uWK2216a5 sD7nQD8NIXFP8sXkXb1l02twLg== X-Received: by 2002:a05:600c:210a:: with SMTP id u10mr4528031wml.147.1615398197012; Wed, 10 Mar 2021 09:43:17 -0800 (PST) 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 x13sm24371wrt.75.2021.03.10.09.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 09:43:16 -0800 (PST) From: Srinivas Kandagatla To: linus.walleij@linaro.org, linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, john.stultz@linaro.org, amit.pundir@linaro.org, bjorn.andersson@linaro.org, Srinivas Kandagatla , Andy Shevchenko Subject: [PATCH v2] gpio: wcd934x: Fix shift-out-of-bounds error Date: Wed, 10 Mar 2021 17:43:04 +0000 Message-Id: <20210310174304.22176-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 --- 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 Reviewed-by: Bjorn Andersson 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