ChangeSet 1.924.3.1, 2002/11/30 00:01:04-08:00, [EMAIL PROTECTED]

[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.


diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
--- a/drivers/usb/serial/usb-serial.c   Sun Dec  1 23:06:33 2002
+++ b/drivers/usb/serial/usb-serial.c   Sun Dec  1 23:06:33 2002
@@ -467,9 +467,13 @@
        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 @@
                                __MOD_DEC_USE_COUNT(serial->type->owner);
                }
        }
+bailout:
 
        up (&port->sem);
        return retval;


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to