can: mcp251xfd: fix wrong check in mcp251xfd_handle_rxif_one
PATCH 1/1 can: mcp251xfd: fix wrong check in mcp251xfd_handle_rxif_one
If alloc_canfd_skb returns NULL, 'cfg' is an uninitialized variable, so we should check 'skb' rather than 'cfd' after calling alloc_canfd_skb(priv->ndev, &cfd).
Fixes 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Signed-off-by Qinglang Miao <[email protected]>
--- 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
@@ -1492,7 +1492,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,else skb =alloc_can_skb (priv->ndev, (struct can_frame **)&cfd); -if (!cfd) { +if (!skb) { stats->rx_dropped++;return 0 ; }
Signature · 1 line
2.23.0
Marc Kleine-Budde
maintainerQuoted 6 lines · Qinglang Miao
If
alloc_canfd_skbreturns NULL, 'cfg' is an uninitialized variable, so we should check 'skb' rather than 'cfd' after callingalloc_canfd_skb(priv->ndev, &cfd).Fixes 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")Signed-off-by Qinglang Miao <[email protected]>
applied to linux-can/testing
Tnx,
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 |
Quoted 6 lines · Qinglang Miao
If
alloc_canfd_skbreturns NULL, 'cfg' is an uninitialized variable, so we should check 'skb' rather than 'cfd' after callingalloc_canfd_skb(priv->ndev, &cfd).Fixes 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")Signed-off-by Qinglang Miao <[email protected]>
Reviewed-by Manivannan Sadhasivam <[email protected]>
Thanks,
Mani
Quoted 20 lines
--- 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@@ -1492,7 +1492,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,else skb =alloc_can_skb (priv->ndev, (struct can_frame **)&cfd); -if (!cfd) { +if (!skb) { stats->rx_dropped++;return 0 ; }Signature · 1 line
2.23.0