Commit 8f19ea83 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] module unload race with usb serial drivers

the serial subdrivers may be unloading while we open.
This patch against 2.5 guards against that.
parent c9e54010
......@@ -467,9 +467,13 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
down (&port->sem);
port->tty = tty;
/* lock this module before we call it */
/* lock this module before we call it,
this may, which means we must bail out, safe because we are called with BKL held */
if (serial->type->owner)
__MOD_INC_USE_COUNT(serial->type->owner);
if (!try_module_get(serial->type->owner)) {
retval = -ENODEV;
goto bailout;
}
++port->open_count;
if (port->open_count == 1) {
......@@ -485,6 +489,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
__MOD_DEC_USE_COUNT(serial->type->owner);
}
}
bailout:
up (&port->sem);
return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment