On Wed, Oct 17, 2001 at 08:39:09AM +0200, Oliver Neukum wrote:
> 
> In your open() method you do MOD_INC_USE_COUNT last.
> This is bad. Your module may be unloaded while you sleep on down() before.
> You must use MOD_INC_USE_COUNT before the first down() and decrement it in 
> the error case.

Good catch, thanks for looking at this.  No use letting old races get
into code after we had audited all of the drivers for this :)

Here's a patch relative to David's original patch that fixes this
problem.

As 2.4.13-pre4 came out without the scanner patch, I'll resubmit it to
Linus with this change.

thanks,

greg k-h


diff --minimal -Nru a/drivers/usb/scanner.c b/drivers/usb/scanner.c
--- a/drivers/usb/scanner.c     Wed Oct 17 16:45:33 2001
+++ b/drivers/usb/scanner.c     Wed Oct 17 16:45:33 2001
@@ -348,6 +348,8 @@
 
        int err=0;
 
+       MOD_INC_USE_COUNT;
+
        down(&scn_mutex);
 
        scn_minor = USB_SCN_MINOR(inode);
@@ -392,11 +394,13 @@
 
        file->private_data = scn; /* Used by the read and write methods */
 
-       MOD_INC_USE_COUNT;
 
 out_error:
 
        up(&(scn->sem)); /* Wake up any possible contending processes */
+
+       if (err)
+               MOD_DEC_USE_COUNT;
 
        return err;
 }

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to