Skip to contentSkip to conversation

can: mcp251xfd: mcp251xfd_handle_ivmif(): fix wrong NULL pointer check

PATCH In review angkery 2 participants 2 messages Jan 19, 2021

Subsystems (4)
lore
Share & tools
lore

angkery

author
#0 lore raw

PATCH 1/1 can: mcp251xfd: mcp251xfd_handle_ivmif(): fix wrong NULL pointer check

From: Junlin Yang <[email protected]>

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

---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +1 -1
index f07e8b7..0af131c 100644
@@ -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);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 3 lines · angkery

From: Junlin Yang <[email protected]>

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

Signature · 4 lines
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 |