[PATCH] can: mcp251xfd: mcp251xfd_handle_ivmif(): fix wrong NULL pointer check

Subsystems: can network drivers, mcp251xfd spi-can network driver, the rest

STALE2031d

2 messages, 2 authors, 2021-01-19 · open the first message on its own page

[PATCH] can: mcp251xfd: mcp251xfd_handle_ivmif(): fix wrong NULL pointer check

From: angkery <hidden>
Date: 2021-01-19 02:07:19

From: Junlin Yang <redacted>

if alloc_can_err_skb() returns NULL, we should check skb instead of cf.

Signed-off-by: Junlin Yang <redacted>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index f07e8b7..0af131c 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -1755,7 +1755,7 @@ static int mcp251xfd_handle_ivmif(struct mcp251xfd_priv *priv)
 			cf->data[2] |= CAN_ERR_PROT_TX | CAN_ERR_PROT_BIT0;
 	}
 
-	if (!cf)
+	if (!skb)
 		return 0;
 
 	err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
-- 
1.9.1

Re: [PATCH] can: mcp251xfd: mcp251xfd_handle_ivmif(): fix wrong NULL pointer check

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2021-01-19 07:57:36

On 1/19/21 3:02 AM, angkery wrote:
From: Junlin Yang <redacted>

if alloc_can_err_skb() returns NULL, we should check skb instead of cf.
Have a look at the function, there is a check for cf several times before this.
But as cf is initialized as NULL this is should be no problem.

While in:

| ca4c6ebeeb50 can: mcp251xfd: mcp251xfd_handle_rxif_one():
|             fix wrong NULL pointer check

a real problem has been fixed.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help