Skip to content

Commit a085f25

Browse files
pchelkin91jfvogel
authored andcommitted
can: ctucanfd: handle skb allocation failure
commit 9bd2492 upstream. If skb allocation fails, the pointer to struct can_frame is NULL. This is actually handled everywhere inside ctucan_err_interrupt() except for the only place. Add the missed NULL check. Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool. Fixes: 2dcb8e8 ("can: ctucanfd: add support for CTU CAN FD open-source IP core - bus independent part.") Cc: [email protected] Signed-off-by: Fedor Pchelkin <[email protected]> Acked-by: Pavel Pisa <[email protected]> Reviewed-by: Vincent Mailhol <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit b0e592dd46a0a952b41c3bf6c963afdd6a42b526) Signed-off-by: Jack Vogel <[email protected]>
1 parent f8e7dcf commit a085f25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/can/ctucanfd/ctucanfd_base.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,12 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr)
867867
}
868868
break;
869869
case CAN_STATE_ERROR_ACTIVE:
870-
cf->can_id |= CAN_ERR_CNT;
871-
cf->data[1] = CAN_ERR_CRTL_ACTIVE;
872-
cf->data[6] = bec.txerr;
873-
cf->data[7] = bec.rxerr;
870+
if (skb) {
871+
cf->can_id |= CAN_ERR_CNT;
872+
cf->data[1] = CAN_ERR_CRTL_ACTIVE;
873+
cf->data[6] = bec.txerr;
874+
cf->data[7] = bec.rxerr;
875+
}
874876
break;
875877
default:
876878
netdev_warn(ndev, "unhandled error state (%d:%s)!\n",

0 commit comments

Comments
 (0)