can: Before we use pstate, we should check if it is NULL.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2024-09-05 10:28:27 +08:00 committed by Xiang Xiao
parent dedb4c95c9
commit e1b9144e71

@ -369,14 +369,15 @@ static uint16_t can_recvfrom_eventhandler(FAR struct net_driver_s *dev,
FAR void *pvpriv, uint16_t flags)
{
struct can_recvfrom_s *pstate = pvpriv;
#if defined(CONFIG_NET_CANPROTO_OPTIONS) || defined(CONFIG_NET_TIMESTAMP)
struct can_conn_s *conn = pstate->pr_conn;
#endif
/* 'priv' might be null in some race conditions (?) */
if (pstate)
{
#if defined(CONFIG_NET_CANPROTO_OPTIONS) || defined(CONFIG_NET_TIMESTAMP)
struct can_conn_s *conn = pstate->pr_conn;
#endif
if ((flags & CAN_NEWDATA) != 0)
{
/* If a new packet is available, check receive filters