Skip to content

Commit

Permalink
can: Before we use pstate, we should check if it is NULL.
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 authored and xiaoxiang781216 committed Sep 5, 2024
1 parent dedb4c9 commit e1b9144
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/can/can_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1b9144

Please sign in to comment.