Skip to content

Commit e1b9144

Browse files
hujun260xiaoxiang781216
authored andcommitted
can: Before we use pstate, we should check if it is NULL.
Signed-off-by: hujun5 <[email protected]>
1 parent dedb4c9 commit e1b9144

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/can/can_recvmsg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,15 @@ static uint16_t can_recvfrom_eventhandler(FAR struct net_driver_s *dev,
369369
FAR void *pvpriv, uint16_t flags)
370370
{
371371
struct can_recvfrom_s *pstate = pvpriv;
372-
#if defined(CONFIG_NET_CANPROTO_OPTIONS) || defined(CONFIG_NET_TIMESTAMP)
373-
struct can_conn_s *conn = pstate->pr_conn;
374-
#endif
375372

376373
/* 'priv' might be null in some race conditions (?) */
377374

378375
if (pstate)
379376
{
377+
#if defined(CONFIG_NET_CANPROTO_OPTIONS) || defined(CONFIG_NET_TIMESTAMP)
378+
struct can_conn_s *conn = pstate->pr_conn;
379+
#endif
380+
380381
if ((flags & CAN_NEWDATA) != 0)
381382
{
382383
/* If a new packet is available, check receive filters

0 commit comments

Comments
 (0)