Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH net-next 0/1] pull-request: can-next 2022-07-21
@ 2022-07-21 16:30 Marc Kleine-Budde
  2022-07-21 16:30 ` [PATCH net-next] can: pch_can: pch_can_error(): initialize errc before using it Marc Kleine-Budde
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2022-07-21 16:30 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello Jakub, hello David,

this is a pull request of 1 patch for net-next/master.

The patch is by Vincent Mailhol and fixes a use on an uninitialized
variable in the pch_can driver (introduced in last pull request to
net-next).

regards,
Marc

---

The following changes since commit 5588d628027092e66195097bdf6835ddf64418b3:

  net/cdc_ncm: Increase NTB max RX/TX values to 64kb (2022-07-21 13:20:28 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-5.20-20220721

for you to fetch changes up to 9950f11211331180269867aef848c7cf56861742:

  can: pch_can: pch_can_error(): initialize errc before using it (2022-07-21 18:19:01 +0200)

----------------------------------------------------------------
linux-can-next-for-5.20-20220721

----------------------------------------------------------------
Vincent Mailhol (1):
      can: pch_can: pch_can_error(): initialize errc before using it

 drivers/net/can/pch_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH net-next] can: pch_can: pch_can_error(): initialize errc before using it
  2022-07-21 16:30 [PATCH net-next 0/1] pull-request: can-next 2022-07-21 Marc Kleine-Budde
@ 2022-07-21 16:30 ` Marc Kleine-Budde
  2022-07-22  2:00   ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2022-07-21 16:30 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Vincent Mailhol,
	Nathan Chancellor, Marc Kleine-Budde

From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>

After commit 3a5c7e4611dd, the variable errc is accessed before being
initialized, c.f. below W=2 warning:

| In function 'pch_can_error',
|     inlined from 'pch_can_poll' at drivers/net/can/pch_can.c:739:4:
| drivers/net/can/pch_can.c:501:29: warning: 'errc' may be used uninitialized [-Wmaybe-uninitialized]
|   501 |                 cf->data[6] = errc & PCH_TEC;
|       |                             ^
| drivers/net/can/pch_can.c: In function 'pch_can_poll':
| drivers/net/can/pch_can.c:484:13: note: 'errc' was declared here
|   484 |         u32 errc, lec;
|       |             ^~~~

Moving errc initialization up solves this issue.

Fixes: 3a5c7e4611dd ("can: pch_can: do not report txerr and rxerr during bus-off")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/all/20220721160032.9348-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/pch_can.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 50f6719b3aa4..32804fed116c 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -489,6 +489,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
 	if (!skb)
 		return;
 
+	errc = ioread32(&priv->regs->errc);
 	if (status & PCH_BUS_OFF) {
 		pch_can_set_tx_all(priv, 0);
 		pch_can_set_rx_all(priv, 0);
@@ -502,7 +503,6 @@ static void pch_can_error(struct net_device *ndev, u32 status)
 		cf->data[7] = (errc & PCH_REC) >> 8;
 	}
 
-	errc = ioread32(&priv->regs->errc);
 	/* Warning interrupt. */
 	if (status & PCH_EWARN) {
 		state = CAN_STATE_ERROR_WARNING;

base-commit: 5588d628027092e66195097bdf6835ddf64418b3
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] can: pch_can: pch_can_error(): initialize errc before using it
  2022-07-21 16:30 ` [PATCH net-next] can: pch_can: pch_can_error(): initialize errc before using it Marc Kleine-Budde
@ 2022-07-22  2:00   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-22  2:00 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev, davem, kuba, linux-can, kernel, mailhol.vincent, nathan

Hello:

This patch was applied to netdev/net-next.git (master)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Thu, 21 Jul 2022 18:30:42 +0200 you wrote:
> From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> 
> After commit 3a5c7e4611dd, the variable errc is accessed before being
> initialized, c.f. below W=2 warning:
> 
> | In function 'pch_can_error',
> |     inlined from 'pch_can_poll' at drivers/net/can/pch_can.c:739:4:
> | drivers/net/can/pch_can.c:501:29: warning: 'errc' may be used uninitialized [-Wmaybe-uninitialized]
> |   501 |                 cf->data[6] = errc & PCH_TEC;
> |       |                             ^
> | drivers/net/can/pch_can.c: In function 'pch_can_poll':
> | drivers/net/can/pch_can.c:484:13: note: 'errc' was declared here
> |   484 |         u32 errc, lec;
> |       |             ^~~~
> 
> [...]

Here is the summary with links:
  - [net-next] can: pch_can: pch_can_error(): initialize errc before using it
    https://git.kernel.org/netdev/net-next/c/9950f1121133

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-07-22  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-21 16:30 [PATCH net-next 0/1] pull-request: can-next 2022-07-21 Marc Kleine-Budde
2022-07-21 16:30 ` [PATCH net-next] can: pch_can: pch_can_error(): initialize errc before using it Marc Kleine-Budde
2022-07-22  2: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