From: Oleksij Rempel Date: Tue, 5 Nov 2019 10:07:08 +0000 (+0100) Subject: can: j1939: main: j1939_ndev_to_priv(): avoid crash if can_ml_priv is NULL X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c48c8c1e2e81e71a0f13b83cc5124333f3750064;p=linux.git can: j1939: main: j1939_ndev_to_priv(): avoid crash if can_ml_priv is NULL This patch avoids a NULL pointer deref crash if ndev->ml_priv is NULL. Reported-by: syzbot+95c8e0d9dffde15b6c5c@syzkaller.appspotmail.com Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol") Signed-off-by: Oleksij Rempel --- diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c index def2f813ffcee..8dc935dc2e546 100644 --- a/net/can/j1939/main.c +++ b/net/can/j1939/main.c @@ -207,6 +207,9 @@ static inline struct j1939_priv *j1939_ndev_to_priv(struct net_device *ndev) { struct can_ml_priv *can_ml_priv = ndev->ml_priv; + if (!can_ml_priv) + return NULL; + return can_ml_priv->j1939_priv; }