Skip to content

Commit

Permalink
usbatm: fix tiny race
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Duncan Sands authored and Greg Kroah-Hartman committed Oct 17, 2006
1 parent e4a20da commit ccf40d6
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/usb/atm/usbatm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *arg)

daemonize(instance->driver->driver_name);
allow_signal(SIGTERM);
instance->thread_pid = get_current()->pid;

complete(&instance->thread_started);

Expand All @@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
return ret;
}

mutex_lock(&instance->serialize);
instance->thread_pid = ret;
mutex_unlock(&instance->serialize);

wait_for_completion(&instance->thread_started);

return 0;
Expand Down

0 comments on commit ccf40d6

Please sign in to comment.