usbatm: fix tiny race
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 <baldrick@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e4a20daa7b
commit
ccf40d62c7
@@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *arg)
|
|||||||
|
|
||||||
daemonize(instance->driver->driver_name);
|
daemonize(instance->driver->driver_name);
|
||||||
allow_signal(SIGTERM);
|
allow_signal(SIGTERM);
|
||||||
|
instance->thread_pid = get_current()->pid;
|
||||||
|
|
||||||
complete(&instance->thread_started);
|
complete(&instance->thread_started);
|
||||||
|
|
||||||
@@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&instance->serialize);
|
|
||||||
instance->thread_pid = ret;
|
|
||||||
mutex_unlock(&instance->serialize);
|
|
||||||
|
|
||||||
wait_for_completion(&instance->thread_started);
|
wait_for_completion(&instance->thread_started);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user