Commit ca4c6ebe authored by Qinglang Miao's avatar Qinglang Miao Committed by Marc Kleine-Budde

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

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: 55e5b97f ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Signed-off-by: default avatarQinglang Miao <miaoqinglang@huawei.com>
Reviewed-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20210113073100.79552-1-miaoqinglang@huawei.comSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent b42b3a27
...@@ -1491,7 +1491,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv, ...@@ -1491,7 +1491,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,
else else
skb = alloc_can_skb(priv->ndev, (struct can_frame **)&cfd); skb = alloc_can_skb(priv->ndev, (struct can_frame **)&cfd);
if (!cfd) { if (!skb) {
stats->rx_dropped++; stats->rx_dropped++;
return 0; return 0;
} }
......
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