From baldrick@free.fr Thu Oct 5 00:56:50 2006 From: Duncan Sands To: Greg KH Subject: usbatm: fix tiny race Date: Thu, 5 Oct 2006 09:56:44 +0200 Content-Disposition: inline Message-Id: <200610050956.44461.baldrick@free.fr> If usbatm_do_heavy_init finishes before usbatm_heavy_init writes the pid, the disconnect method could shoot down the wrong process if the pid has been recycled. Signed-off-by: Duncan Sands Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/usbatm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- gregkh-2.6.orig/drivers/usb/atm/usbatm.c +++ gregkh-2.6/drivers/usb/atm/usbatm.c @@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *ar daemonize(instance->driver->driver_name); allow_signal(SIGTERM); + instance->thread_pid = get_current()->pid; complete(&instance->thread_started); @@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usba return ret; } - mutex_lock(&instance->serialize); - instance->thread_pid = ret; - mutex_unlock(&instance->serialize); - wait_for_completion(&instance->thread_started); return 0;