Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1698362rwd; Thu, 18 May 2023 16:15:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CQK6V/3axygkTJdboT+4H2gBwdJu3QBPp7jRc/Ige427qoNu5BPIwKAoy6bLpmon/mED0 X-Received: by 2002:a05:6a00:842:b0:647:4dee:62a4 with SMTP id q2-20020a056a00084200b006474dee62a4mr529931pfk.34.1684451726146; Thu, 18 May 2023 16:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684451726; cv=none; d=google.com; s=arc-20160816; b=XuaZ8sQuFM3HiNB/IVaBUXJNLFwk2YOHahE/ClqsioUQKQPFJ5R8qGh3fNPcFcxN/x BvM8wwP73XusA3Wm0LHCy0hyCdPMEyKlODstEr3v6FlLwiVvyv62Qqp3ly8zqK5r5a0n LJIhTIDOaH2S9uqi09a4OYtQyjXazRPkBEKpV6TGGwDkZ1dpgpu85g47LJzR3luYS3be hU6C3DrR9jKMDE9TB3UGBl7Rx4YoEf4snAwsmQo3a2UJorZKeJBW67oE21wecAwMiRik JR4GInbYnbP8PuR9c6a1GfSEE5P0pujVxPmqjNwXGgkrZFqcK9BibJxjiQ9XbZi9mIO8 upvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cIB5nolYlR7mZtM7NMk4WurxovvarDu47ffDj2xUgaI=; b=UMDi/o5Hj8JWYE03BZ3wj8ZUN19D/LyCWlfTXzzxpDWb+nvJqcXYXmnxqz/dJaze3Y iIHBwokPmfKQI3Oa+TsH6XkImzf6znVrh9o+vwUBSAMEMWSBDXaGIC7JNa6pEmExyfmb +b4WZfWtTFlVn12M6IegoHsysKdv1tSefjJA9fOmBYE9mVJ8SYux9hot1+9R4ibDtmjf nwc0q26fbk7bKMgO29cBcez6TbCv/q8yWx3AixkDyaO8a/xUsx/2KooZRjuN78Zu4kyw iHfkSmzPyxfsle5Zb11nRXhwXSBeRO0u0NAhd7I9JmAApeDFuI5fWRx3gcG3e+WFD0bu V8Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=EhJgky4O; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m185-20020a6258c2000000b005e1cabb612fsi2893817pfb.67.2023.05.18.16.15.14; Thu, 18 May 2023 16:15:26 -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=@broadcom.com header.s=google header.b=EhJgky4O; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjERXG1 (ORCPT + 99 others); Thu, 18 May 2023 19:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjERXG0 (ORCPT ); Thu, 18 May 2023 19:06:26 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACF718D for ; Thu, 18 May 2023 16:06:25 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-25348d724f2so398934a91.0 for ; Thu, 18 May 2023 16:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1684451185; x=1687043185; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cIB5nolYlR7mZtM7NMk4WurxovvarDu47ffDj2xUgaI=; b=EhJgky4OdgM86fs0x3LyOes6hLpgtE3xSHUR576ODesiJFfCIEwI4K2JyLeKLnAQFL lU19bEuOcjKucmsqagyFJYBzOX2oGGJiFeLcg5tWi/l/55ueB70VpBbKSSmMfMj5k4B0 EKn6FibDF3cccfDbmYR7iAOropbkOQW3lRpIM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684451185; x=1687043185; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cIB5nolYlR7mZtM7NMk4WurxovvarDu47ffDj2xUgaI=; b=PhnG2CdfATxfPOguEc0x8M8BIzTKeXNWd8/I2oiVyPFhvPQnKiX1n2ywcZleuEvRpB vXpsWAEhWEVZDLo7OYGSzdOnUQygAgQtk4J8PgvcQiDhEn4pEReUDD//h5+zusUe+icq MftL6osd1YxAhjJ2816XGjbpBxBDulCt7Gk0/BPqYOeW/oh2trjoHaN9n3Ka1h23509f iocwV46kMoKOdnlqndB5FLSRWODWTJ2TU97cVQ/lB+BSOLNoFKcUEbMiccjsq7Dg0A/a soL0mTxnS8JPmfzB3x4jbUhEtlMDSAQMkqRoJm+Q+7rzn/y05RSuMajdtAXtEu6Q509G RmNw== X-Gm-Message-State: AC+VfDzCcU8aF5WVeH4NEr57ZUtnodLcrzHlbxqv1RbFLhNiD57Eo/DH OoZoyurE1Z7n+72jG2MCgE38lj7muoH+ezT7zco3LPABSGqzBrwAruhK9Q== X-Received: by 2002:a17:90b:3ecd:b0:24e:102c:10cc with SMTP id rm13-20020a17090b3ecd00b0024e102c10ccmr241203pjb.4.1684451184699; Thu, 18 May 2023 16:06:24 -0700 (PDT) MIME-Version: 1.0 References: <20230513112931.176066-1-krzysztof.kozlowski@linaro.org> In-Reply-To: <20230513112931.176066-1-krzysztof.kozlowski@linaro.org> From: Markus Mayer Date: Thu, 18 May 2023 16:06:13 -0700 Message-ID: Subject: Re: [PATCH] memory: brcmstb_dpfe: fix testing array offset after use To: Krzysztof Kozlowski Cc: Broadcom internal kernel review list , Florian Fainelli , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Sat, 13 May 2023 at 04:29, Krzysztof Kozlowski wrote: > > 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 > Acked-by: Markus Mayer