* [PATCH] can: janz-ican3: initialize dlc variable
@ 2022-01-08 14:33 trix
2022-01-08 16:11 ` Vincent MAILHOL
2022-01-09 17:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: trix @ 2022-01-08 14:33 UTC (permalink / raw)
To: wg, mkl, davem, kuba, nathan, ndesaulniers, mailhol.vincent,
stefan.maetje
Cc: linux-can, netdev, linux-kernel, llvm, Tom Rix
From: Tom Rix <trix@redhat.com>
Clang static analysis reports this problem
janz-ican3.c:1311:2: warning: Undefined or garbage value returned to caller
return dlc;
^~~~~~~~~~
dlc is only set with this conditional
if (!(cf->can_id & CAN_RTR_FLAG))
dlc = cf->len;
But is always returned. So initialize dlc to 0.
Fixes: cc4b08c31b5c ("can: do not increase tx_bytes statistics for RTR frames")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/net/can/janz-ican3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index 5b677af5f2a41..808c105cf8f7e 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -1285,7 +1285,7 @@ static unsigned int ican3_get_echo_skb(struct ican3_dev *mod)
{
struct sk_buff *skb = skb_dequeue(&mod->echoq);
struct can_frame *cf;
- u8 dlc;
+ u8 dlc = 0;
/* this should never trigger unless there is a driver bug */
if (!skb) {
--
2.26.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] can: janz-ican3: initialize dlc variable
2022-01-08 14:33 [PATCH] can: janz-ican3: initialize dlc variable trix
@ 2022-01-08 16:11 ` Vincent MAILHOL
2022-01-09 17:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Vincent MAILHOL @ 2022-01-08 16:11 UTC (permalink / raw)
To: trix
Cc: wg, mkl, davem, kuba, nathan, ndesaulniers, Stefan.Maetje,
linux-can, netdev, linux-kernel, llvm
On Sat. 8 Jan 2022 à 23:33, <trix@redhat.com> wrote:
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this problem
> janz-ican3.c:1311:2: warning: Undefined or garbage value returned to caller
> return dlc;
> ^~~~~~~~~~
>
> dlc is only set with this conditional
> if (!(cf->can_id & CAN_RTR_FLAG))
> dlc = cf->len;
>
> But is always returned. So initialize dlc to 0.
Yes. The actual intent is to return a length of 0 for RTR frames.
> Fixes: cc4b08c31b5c ("can: do not increase tx_bytes statistics for RTR frames")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
> drivers/net/can/janz-ican3.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
> index 5b677af5f2a41..808c105cf8f7e 100644
> --- a/drivers/net/can/janz-ican3.c
> +++ b/drivers/net/can/janz-ican3.c
> @@ -1285,7 +1285,7 @@ static unsigned int ican3_get_echo_skb(struct ican3_dev *mod)
> {
> struct sk_buff *skb = skb_dequeue(&mod->echoq);
> struct can_frame *cf;
> - u8 dlc;
> + u8 dlc = 0;
>
> /* this should never trigger unless there is a driver bug */
> if (!skb) {
> --
> 2.26.3
I missed that when writing the patch.
I thought that I did my due diligence by running a "make W=1"
with GCC but I did not catch the error. I should have been more
precocious and run a "make W=2".
Thank you.
Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] can: janz-ican3: initialize dlc variable
2022-01-08 14:33 [PATCH] can: janz-ican3: initialize dlc variable trix
2022-01-08 16:11 ` Vincent MAILHOL
@ 2022-01-09 17:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-09 17:00 UTC (permalink / raw)
To: Tom Rix
Cc: wg, mkl, davem, kuba, nathan, ndesaulniers, mailhol.vincent,
stefan.maetje, linux-can, netdev, linux-kernel, llvm
Hello:
This patch was applied to netdev/net-next.git (master)
by Marc Kleine-Budde <mkl@pengutronix.de>:
On Sat, 8 Jan 2022 06:33:19 -0800 you wrote:
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this problem
> janz-ican3.c:1311:2: warning: Undefined or garbage value returned to caller
> return dlc;
> ^~~~~~~~~~
>
> [...]
Here is the summary with links:
- can: janz-ican3: initialize dlc variable
https://git.kernel.org/netdev/net-next/c/c57979256283
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-09 17:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 14:33 [PATCH] can: janz-ican3: initialize dlc variable trix
2022-01-08 16:11 ` Vincent MAILHOL
2022-01-09 17:00 ` patchwork-bot+netdevbpf
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 NNTP newsgroup(s).