summaryrefslogtreecommitdiff
path: root/drivers/memory/brcmstb_dpfe.c
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>2023-05-13 14:29:31 +0300
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>2023-05-30 11:25:24 +0300
commit1d9e93fad549bc38f593147479ee063f2872c170 (patch)
tree6980243f23d41b3b8c4f22eb8fb382859497c285 /drivers/memory/brcmstb_dpfe.c
parent3d56c7364389fce14547803fef56d6f2cab5d366 (diff)
downloadlinux-1d9e93fad549bc38f593147479ee063f2872c170.tar.xz
memory: brcmstb_dpfe: fix testing array offset after use
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") Acked-by: Markus Mayer <mmayer@broadcom.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://lore.kernel.org/r/20230513112931.176066-1-krzysztof.kozlowski@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Diffstat (limited to 'drivers/memory/brcmstb_dpfe.c')
-rw-r--r--drivers/memory/brcmstb_dpfe.c4
1 files changed, 3 insertions, 1 deletions
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 */