Commit 9950f112 authored by Vincent Mailhol's avatar Vincent Mailhol Committed by Marc Kleine-Budde

can: pch_can: pch_can_error(): initialize errc before using it

After commit 3a5c7e46, 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: 3a5c7e46 ("can: pch_can: do not report txerr and rxerr during bus-off")
Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/all/20220721160032.9348-1-mailhol.vincent@wanadoo.frSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 5588d628
...@@ -489,6 +489,7 @@ static void pch_can_error(struct net_device *ndev, u32 status) ...@@ -489,6 +489,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
if (!skb) if (!skb)
return; return;
errc = ioread32(&priv->regs->errc);
if (status & PCH_BUS_OFF) { if (status & PCH_BUS_OFF) {
pch_can_set_tx_all(priv, 0); pch_can_set_tx_all(priv, 0);
pch_can_set_rx_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) ...@@ -502,7 +503,6 @@ static void pch_can_error(struct net_device *ndev, u32 status)
cf->data[7] = (errc & PCH_REC) >> 8; cf->data[7] = (errc & PCH_REC) >> 8;
} }
errc = ioread32(&priv->regs->errc);
/* Warning interrupt. */ /* Warning interrupt. */
if (status & PCH_EWARN) { if (status & PCH_EWARN) {
state = CAN_STATE_ERROR_WARNING; state = CAN_STATE_ERROR_WARNING;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment