]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
can: Add missing socket check in can/bcm release.
authorDave Jones <davej@redhat.com>
Wed, 20 Apr 2011 03:36:59 +0000 (20:36 -0700)
committerAndi Kleen <ak@linux.intel.com>
Mon, 1 Aug 2011 20:54:44 +0000 (13:54 -0700)
commit c6914a6f261aca0c9f715f883a353ae7ff51fe83 upstream.

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

Signed-off-by: Dave Jones <davej@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
net/can/bcm.c

index 9d5e8accfab1d73f25e8a00ae45523a400b820ce..56d20a29a7e97758ba85eae75b7c8440c6970184 100644 (file)
@@ -1424,9 +1424,14 @@ static int bcm_init(struct sock *sk)
 static int bcm_release(struct socket *sock)
 {
        struct sock *sk = sock->sk;
-       struct bcm_sock *bo = bcm_sk(sk);
+       struct bcm_sock *bo;
        struct bcm_op *op, *next;
 
+       if (sk == NULL)
+               return 0;
+
+       bo = bcm_sk(sk);
+
        /* remove bcm_ops, timer, rx_unregister(), etc. */
 
        unregister_netdevice_notifier(&bo->notifier);