lkml.org 
[lkml]   [2000]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectWhy is lock_kernel() in jsf_release()?
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [from the cache]
©2003-2011 Jasper Spaans