Busmouse MOD_INC_USE_COUNT race fix

From: Russell King (rmk@arm.linux.org.uk)
Date: Wed May 31 2000 - 08:51:40 EST


Hi,

Here is the fix the MOD_INC_USE_COUNT race for busmouse.c, generated against
2.4.0-test1-ac6, but should apply to any 2.4.0-test1 kernel.

--- orig/drivers/char/busmouse.c Wed May 31 13:12:14 2000
+++ linux/drivers/char/busmouse.c Wed May 31 12:50:53 2000
@@ -192,6 +192,8 @@
         if (mousedev >= NR_MICE)
                 return -EINVAL;
         
+ MOD_INC_USE_COUNT;
+
         down(&mouse_sem);
         mse = busmouse_data[mousedev];
         if (!mse)
@@ -210,8 +212,6 @@
         if (mse->active++)
                 goto end;
 
- MOD_INC_USE_COUNT;
-
         spin_lock_irq(&mse->lock);
 
         mse->ready = 0;
@@ -225,6 +225,9 @@
         spin_unlock_irq(&mse->lock);
 end:
         up(&mouse_sem);
+
+ if (ret)
+ MOD_DEC_USE_COUNT;
         return ret;
 }
 

   _____
  |_____| ------------------------------------------------- ---+---+-
  | | Russell King rmk@arm.linux.org.uk --- ---
  | | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
  | +-+-+ --- -+-
  / | THE developer of ARM Linux |+| /|\
 / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:27 EST