summaryrefslogtreecommitdiffstats
path: root/net/can
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2019-11-05 11:07:08 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2019-11-13 10:42:34 +0100
commitc48c8c1e2e81e71a0f13b83cc5124333f3750064 (patch)
tree14c1cad59500c38b1f03b4d0ca840b8753c8bcff /net/can
parent25fe97cb7620ef2e6b4f44ef0de4e371adf6c1d0 (diff)
downloadlinux-c48c8c1e2e81e71a0f13b83cc5124333f3750064.tar.bz2
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 <o.rempel@pengutronix.de>
Diffstat (limited to 'net/can')
-rw-r--r--net/can/j1939/main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index def2f813ffce..8dc935dc2e54 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;
}