Why is lock_kernel() in jsf_release()?

From: Pete Zaitcev (zaitcev@metabyte.com)
Date: Thu Jul 13 2000 - 11:04:09 EST


Hi,

DaveM just did the following change to jsflash.c:

Index: drivers/sbus/char/jsflash.c
diff -u -r1.13 -r1.14
--- jsflash.c 2000/07/06 01:41:37 1.13
+++ jsflash.c 2000/07/13 08:06:40 1.14
@@ -35,6 +35,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/string.h>
+#include <linux/smp_lock.h>
 
 /*
  * <linux/blk.h> is controlled from the outside with these definitions.
@@ -504,7 +505,9 @@
 
 static int jsf_release(struct inode *inode, struct file *file)
 {
+ lock_kernel();
        jsf0.busy = 0;
+ unlock_kernel();
        return 0;
 }

For the reference, this is how jsf_open() looks:

tatic int jsf_open(struct inode * inode, struct file * filp)
{
        if (jsf0.base == 0) return -ENXIO;
        if (test_and_set_bit(0, (void *)&jsf0.busy) != 0)
                return -EBUSY;
        return 0;
}

Why was the lock necessary? From what race scenario do we
protect ourselves here?

--Pete

-
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 : Sat Jul 15 2000 - 21:00:19 EST