Skip to contentSkip to conversation

: Fix tiny race between module unload and sock_ioctl.

PATCH Applied Pavel Emelyanov 2 participants 2 messages Mar 21, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Fix tiny race between module unload and sock_ioctl.

This is a narrow pedantry :) but the dlci_ioctl_hook check and call should not be parted with the mutex lock.

---

net/socket.c +3 -4
index b6d35cd..9d3fbfb 100644
@@ -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);