2021-01-19 05:51:20

by angkery

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Junlin Yang <[email protected]>
---
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



2021-01-19 07:59:14

by Marc Kleine-Budde

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

On 1/19/21 3:02 AM, angkery wrote:
> 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

--
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 |


Attachments:
signature.asc (499.00 B)
OpenPGP digital signature