* [PATCH] memory: brcmstb_dpfe: fix testing array offset after use
@ 2023-05-13 11:29 Krzysztof Kozlowski
2023-05-18 22:50 ` Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-13 11:29 UTC (permalink / raw
To: Markus Mayer, Broadcom internal kernel review list,
Krzysztof Kozlowski, Florian Fainelli, linux-arm-kernel,
linux-kernel
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 <krzysztof.kozlowski@linaro.org>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: brcmstb_dpfe: fix testing array offset after use
2023-05-13 11:29 [PATCH] memory: brcmstb_dpfe: fix testing array offset after use Krzysztof Kozlowski
@ 2023-05-18 22:50 ` Florian Fainelli
2023-05-18 23:06 ` Markus Mayer
2023-05-30 8:26 ` Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2023-05-18 22:50 UTC (permalink / raw
To: Krzysztof Kozlowski, Markus Mayer,
Broadcom internal kernel review list, Florian Fainelli,
linux-arm-kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 471 bytes --]
On 5/13/23 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 <krzysztof.kozlowski@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: brcmstb_dpfe: fix testing array offset after use
2023-05-13 11:29 [PATCH] memory: brcmstb_dpfe: fix testing array offset after use Krzysztof Kozlowski
2023-05-18 22:50 ` Florian Fainelli
@ 2023-05-18 23:06 ` Markus Mayer
2023-05-30 8:26 ` Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Markus Mayer @ 2023-05-18 23:06 UTC (permalink / raw
To: Krzysztof Kozlowski
Cc: Broadcom internal kernel review list, Florian Fainelli,
linux-arm-kernel, linux-kernel
On Sat, 13 May 2023 at 04:29, Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> 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 <krzysztof.kozlowski@linaro.org>
> ---
> 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 <mmayer@broadcom.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: brcmstb_dpfe: fix testing array offset after use
2023-05-13 11:29 [PATCH] memory: brcmstb_dpfe: fix testing array offset after use Krzysztof Kozlowski
2023-05-18 22:50 ` Florian Fainelli
2023-05-18 23:06 ` Markus Mayer
@ 2023-05-30 8:26 ` Krzysztof Kozlowski
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-30 8:26 UTC (permalink / raw
To: Markus Mayer, Broadcom internal kernel review list,
Florian Fainelli, linux-arm-kernel, linux-kernel,
Krzysztof Kozlowski
On Sat, 13 May 2023 13:29:31 +0200, 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.
>
>
Applied, thanks!
[1/1] memory: brcmstb_dpfe: fix testing array offset after use
https://git.kernel.org/krzk/linux-mem-ctrl/c/1d9e93fad549bc38f593147479ee063f2872c170
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-30 8:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-13 11:29 [PATCH] memory: brcmstb_dpfe: fix testing array offset after use Krzysztof Kozlowski
2023-05-18 22:50 ` Florian Fainelli
2023-05-18 23:06 ` Markus Mayer
2023-05-30 8:26 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).