[DLCI]: Fix tiny race between module unload and sock_ioctl.
authorPavel Emelyanov <xemul@openvz.org>
Fri, 21 Mar 2008 22:58:52 +0000 (15:58 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Mar 2008 22:58:52 +0000 (15:58 -0700)
This is a narrow pedantry :) but the dlci_ioctl_hook check and call
should not be parted with the mutex lock.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/socket.c

index b6d35cd72a50988e2075683ff757902ec7af6ccc..9d3fbfbc8535c8b3f2e0639990098730ba4ecbc7 100644 (file)
@@ -909,11 +909,10 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
                        if (!dlci_ioctl_hook)
                                request_module("dlci");
 
-                       if (dlci_ioctl_hook) {
-                               mutex_lock(&dlci_ioctl_mutex);
+                       mutex_lock(&dlci_ioctl_mutex);
+                       if (dlci_ioctl_hook)
                                err = dlci_ioctl_hook(cmd, argp);
-                               mutex_unlock(&dlci_ioctl_mutex);
-                       }
+                       mutex_unlock(&dlci_ioctl_mutex);
                        break;
                default:
                        err = sock->ops->ioctl(sock, cmd, arg);