Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp11487647rwr; Sat, 13 May 2023 04:42:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Hpr6tJeKvXold0uwtoj/jKOks0oRjAja5aB6j5vB28Nnbpmoav/nsdOttBrwNdfsyl+Yk X-Received: by 2002:a05:6a20:8427:b0:101:b77:fdad with SMTP id c39-20020a056a20842700b001010b77fdadmr23147043pzd.2.1683978154345; Sat, 13 May 2023 04:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683978154; cv=none; d=google.com; s=arc-20160816; b=pFnbnuBM4YM4/y8tYlBrtAjLbonUAzokXDjLKi17IhI7TbEv93+FqPZLfsuYBA+lG0 2vzxeHhph2EsbCEHhSQP1x3j4X5EKl1xhtP+uSRinYKUsH9lTFWTk4a1/Pe5OzVLycoD I5JQL+VOsvBUEGZd2rnZjB0ndo4AGiHF0SbLH0fDb6Im3E3QQzWZutiN6uLBFkzqNlAo rzR8+vK9ADVPElm6LI9owrg42wPCYngXAA0AWuVGmUooNMmNaHmDq8HFLfY9ZlRMMPvM Ult9IMLrzRzp51s2ISJK8WJk+i6B/0R9EW9MJyrJdBmVs480poZFAazk3EWet9C8s0e3 uA2A== 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:to:from:dkim-signature; bh=dw8wPKVLlAIKAMysuZNl/3ACPQu4RWpxUdT8LT4hWo0=; b=fLnKEUV5iNvu7Bp/p3PxS291JGW2OtbT5N6bS3XywqVXcBawmCY6iJpzlLXIV8esbK RkX96R+TMUzS3H2nVvhipNwjHG2CwW0GMNVH9e7kbrtLwPjWjMs2kjXLpfOMywrc9yDU bYIURgonK0Vo7UdYayYMzX/mVSci2oH6KnFAzetsUa0s0aO4/iJaVftzxOtlqiynCPwB Lep8Bm7aLrRQv4Db55ett3nLxxbenjD02FMFEzZ0pDlrMjvSjSzxulSZiWIez7i97iLV vhFfS2AgvzGSahx2wkFTCm6Sjf7wS1gKsep8qmrHdBFl7w42B3CaHevKpLj095pp7QX9 UhAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BANXOOpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a63b254000000b0052cb36e0c00si7215815pgo.223.2023.05.13.04.42.22; Sat, 13 May 2023 04:42:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BANXOOpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S237968AbjEML3m (ORCPT + 99 others); Sat, 13 May 2023 07:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238046AbjEML3i (ORCPT ); Sat, 13 May 2023 07:29:38 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6406D3C0F for ; Sat, 13 May 2023 04:29:37 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so97014655a12.0 for ; Sat, 13 May 2023 04:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683977376; x=1686569376; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=dw8wPKVLlAIKAMysuZNl/3ACPQu4RWpxUdT8LT4hWo0=; b=BANXOOpT30CoBj7RkcqtZKO5BBKhLQ++YG+7Cuo/9l72d+cZP/5oTwPU9flVqa8Iiv vbS2gilvw8hHA2m5ll9pB3x1SMMW0aYzOD68TO1LkbxpGmtAYq58u/fVGvKu2HjpIuMW 2zT/mWfNVgPPledpOMI0zncFj7b80KN0rwroBGUM/zMZcSS2fz/zSA4H4wIfq6XS6dJs /aadrDje9R/AGlgAThuQUL9+j6/fS1DmL9ommyb3n6pmPxv2jkZ1O4p3Pc3lJ1xkHCjX xr4sprhofemVkyWzpulyAJNE3jPCKqZiduiClUs1A1kIItcJUeH3Qj27D+GO0ikxK0LD GzJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683977376; x=1686569376; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dw8wPKVLlAIKAMysuZNl/3ACPQu4RWpxUdT8LT4hWo0=; b=CWZ1N5qz8y9kZ4/OTsx2GLCmtAm6o1X3g7IP4BHqkfeI0QeWBtNEH1NQxxgvvnqqDL YNDQZYrbSAVBAtmjgm/kjwFuOg+eXt4CO69lV4QBW7q/BK+AXN3n2oFn5AGbmc1NuX1x OOWVAvU+A65GsM7WC/ASBXlccQRYva/zn53OwP4YrTE55dmuZSZRmTUJL2Bc6aPHNs3y Q52k9QMH4Z1oBm65G3Me4PXPhym3bHyoC/ChZU9Ur4S3v1MS9Vv0sXq9f1NWaO9SExa0 cVANj873QAc86dcdRjh4TyF4BCHe4Hb8kqsspxXs7VRQdycIWyE9N8opJVfuaRsBjOrM AZ8Q== X-Gm-Message-State: AC+VfDzX+rMFnDXgK6G0yoeDUrJDAoFKqYvF1E1XiKd4lFE/YAOqqc7M Zs94r4U5wHw2mxjsTtuoGCIn363zoGaTB+W9byW8iA== X-Received: by 2002:a05:6402:2711:b0:50d:8bc9:41c8 with SMTP id y17-20020a056402271100b0050d8bc941c8mr23187153edd.13.1683977375908; Sat, 13 May 2023 04:29:35 -0700 (PDT) Received: from krzk-bin.. ([2a02:810d:15c0:828:a3aa:fd4:f432:676b]) by smtp.gmail.com with ESMTPSA id r9-20020aa7c149000000b00509d1c6dcefsm4806493edp.13.2023.05.13.04.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 04:29:35 -0700 (PDT) From: Krzysztof Kozlowski To: Markus Mayer , Broadcom internal kernel review list , Krzysztof Kozlowski , Florian Fainelli , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] memory: brcmstb_dpfe: fix testing array offset after use Date: Sat, 13 May 2023 13:29:31 +0200 Message-Id: <20230513112931.176066-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Code should first check for valid value of array offset, then use it as the index. Fixes smatch warning: drivers/memory/brcmstb_dpfe.c:443 __send_command() error: testing array offset 'cmd' after use. Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE") Signed-off-by: Krzysztof Kozlowski --- drivers/memory/brcmstb_dpfe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index 76c82e9c8fce..9339f80b21c5 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -434,15 +434,17 @@ static void __finalize_command(struct brcmstb_dpfe_priv *priv) static int __send_command(struct brcmstb_dpfe_priv *priv, unsigned int cmd, u32 result[]) { - const u32 *msg = priv->dpfe_api->command[cmd]; void __iomem *regs = priv->regs; unsigned int i, chksum, chksum_idx; + const u32 *msg; int ret = 0; u32 resp; if (cmd >= DPFE_CMD_MAX) return -1; + msg = priv->dpfe_api->command[cmd]; + mutex_lock(&priv->lock); /* Wait for DCPU to become ready */ -- 2.34.1