can: add missing socket check in can/raw release

v2: added space after 'if' according code style.

We can get here with a NULL socket argument passed from userspace,
so we need to handle it accordingly.

Thanks to Dave Jones pointing at this issue in net/can/bcm.c

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Oliver Hartkopp and committed by David S. Miller 10022a6c 2430af8b

+6 -1
+6 -1
net/can/raw.c
··· 305 static int raw_release(struct socket *sock) 306 { 307 struct sock *sk = sock->sk; 308 - struct raw_sock *ro = raw_sk(sk); 309 310 unregister_netdevice_notifier(&ro->notifier); 311
··· 305 static int raw_release(struct socket *sock) 306 { 307 struct sock *sk = sock->sk; 308 + struct raw_sock *ro; 309 + 310 + if (!sk) 311 + return 0; 312 + 313 + ro = raw_sk(sk); 314 315 unregister_netdevice_notifier(&ro->notifier); 316