can: j1939: socket: j1939_sk_bind(): make sure ml_priv is allocated
authorOleksij Rempel <o.rempel@pengutronix.de>
Fri, 7 Aug 2020 10:51:58 +0000 (12:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Aug 2020 09:48:58 +0000 (11:48 +0200)
commita14e7ce59232430d582c7d78b4f591d50b69f7ad
treea5b88c4d00b0c394a340acc9998558239eeab20e
parentcf3b3ffb272c6146da2c6f9afa59980a7aa78ef0
can: j1939: socket: j1939_sk_bind(): make sure ml_priv is allocated

commit af804b7826350d5af728dca4715e473338fbd7e5 upstream.

This patch adds check to ensure that the struct net_device::ml_priv is
allocated, as it is used later by the j1939 stack.

The allocation is done by all mainline CAN network drivers, but when using
bond or team devices this is not the case.

Bail out if no ml_priv is allocated.

Reported-by: syzbot+f03d384f3455d28833eb@syzkaller.appspotmail.com
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Cc: linux-stable <stable@vger.kernel.org> # >= v5.4
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://lore.kernel.org/r/20200807105200.26441-4-o.rempel@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/can/j1939/socket.c