From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 842C2C433E9 for ; Tue, 9 Mar 2021 10:20:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C78B65267 for ; Tue, 9 Mar 2021 10:20:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhCIKTy (ORCPT ); Tue, 9 Mar 2021 05:19:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbhCIKTV (ORCPT ); Tue, 9 Mar 2021 05:19:21 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B333BC06174A for ; Tue, 9 Mar 2021 02:19:20 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id m20-20020a7bcb940000b029010cab7e5a9fso5566343wmi.3 for ; Tue, 09 Mar 2021 02:19:20 -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=NqqC6SQUEQuZG42S5a7XSjHw70jA4gnyRLBohP9llLw=; b=x5YvnC5iXjPAJohXYBEbSIy0HZPmiFbayH6tch3XI7Q7smCjaVsjooGV4juSSQj6o+ oTdbOtYduT7A0+ns9ly5xJK+NWzOlfPsLqM9yhnEE1blgGvuivq+9PAExi80XnU/W5Ic gQnbvs/a4VUkJqK+vjCUfI1yZYnZ3B9k1aXhCLWXZ19IxAkFFiqSdpc5F9XX+lpHnJSM ZEbPSn8Mxy5FWNdhhxfvTVltd5pTEAXPAXmNNGFeOh0acb+wvXRlaoODima/leRxSCGP 6Ms4WmayIIW1KQgPpOS8NY00bBEXJ/htHQTsRwmh7QbH+RuvT/UNfLRayvoeBNG3u6lO OAbA== 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=NqqC6SQUEQuZG42S5a7XSjHw70jA4gnyRLBohP9llLw=; b=su0xo+1tOAZ2Pu+cwMamKKbm1Ocqi1SUcuNz8vg+vYzXPpfak80rpXFvGZwSxFfSrK /9YNoV+J7cAoKhrXO2kntcI7Jk1OH00PDTaoAHfO7cSamATHuPdP42zmQ/ha2o9IfnSR SWFftqDKyyDJ/yAxXE7vV/8Znt3V/sW3l1fGEkPWcxLnssFZ8+DJa7F7pX1lIbEO5xWt ewB2nh+Eq7gZ+i8jwSoyFIuBdGpTMGy/cZ+1pc+ZWl/3ajG7WVc7pz0cfcmfYYgh3Vhl XPoajBt+dViObjkMwNz2DLqzSrWP6BuNq9DuIiMNOju0jxGrpJX9JBtQdbeHKMysvTzb eFGQ== X-Gm-Message-State: AOAM530lBAAPByeFEjxD4EasKcS4TuazZV2vihr91ywFa/3cWsp5MYYF VDb5xKXumpesEzSrO+M18V7Sjw== X-Google-Smtp-Source: ABdhPJwSH3cocfW376KwxeOMrBcrrTXnAKNZGAM8NtboawDvWfvpZNbnFh+KAfNXoBJzlgN44sHv6A== X-Received: by 2002:a7b:c050:: with SMTP id u16mr3204641wmc.90.1615285159475; Tue, 09 Mar 2021 02:19:19 -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 y16sm22981951wrh.3.2021.03.09.02.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 02:19:19 -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 Subject: [PATCH] gpio: wcd934x: Fix shift-out-of-bounds error Date: Tue, 9 Mar 2021 10:19:08 +0000 Message-Id: <20210309101908.27688-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 /workspace/dev/linux/drivers/gpio/gpio-wcd934x.c:34:14 qcom-q6v5-mss 4080000.remoteproc: failed to acquire pdc reset remoteproc remoteproc2: releasing 4080000.remoteproc shift exponent 4294967295 is too large for 64-bit type 'long unsigned int' CPU: 6 PID: 155 Comm: kworker/6:2 Not tainted 5.12.0-rc1-00045-g508b7280ec3d-dirty #1396 Hardware name: Thundercomm Dragonboard 845c (DT) Call trace: dump_backtrace+0x0/0x1c0 show_stack+0x18/0x68 dump_stack+0xd8/0x134 ubsan_epilogue+0x10/0x58 __ubsan_handle_shift_out_of_bounds+0xf8/0x168 wcd_gpio_get_direction+0xc8/0xd8 gpiochip_add_data_with_key+0x4ac/0xe78 devm_gpiochip_add_data_with_key+0x30/0x90 wcd_gpio_probe+0xc8/0x118 platform_probe+0x6c/0x118 really_probe+0x24c/0x418 driver_probe_device+0x68/0xf0 __device_attach_driver+0xb4/0x110 Fixes: 59c324683400 ("gpio: wcd934x: Add support to wcd934x gpio controller") Signed-off-by: Srinivas Kandagatla --- drivers/gpio/gpio-wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.21.0