Skip to content

Commit 1d9e93f

Browse files
committed
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: 2f330ca ("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>
1 parent 3d56c73 commit 1d9e93f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/memory/brcmstb_dpfe.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,17 @@ static void __finalize_command(struct brcmstb_dpfe_priv *priv)
434434
static int __send_command(struct brcmstb_dpfe_priv *priv, unsigned int cmd,
435435
u32 result[])
436436
{
437-
const u32 *msg = priv->dpfe_api->command[cmd];
438437
void __iomem *regs = priv->regs;
439438
unsigned int i, chksum, chksum_idx;
439+
const u32 *msg;
440440
int ret = 0;
441441
u32 resp;
442442

443443
if (cmd >= DPFE_CMD_MAX)
444444
return -1;
445445

446+
msg = priv->dpfe_api->command[cmd];
447+
446448
mutex_lock(&priv->lock);
447449

448450
/* Wait for DCPU to become ready */

0 commit comments

Comments
 (0)