[PATCH 3/3] lguest: force file->private_data to be NULL on open()

From: Martin Kepplinger
Date: Sat Oct 18 2014 - 20:33:26 EST


if we depend on private_data being NULL in write() before initialize()
make sure it is NULL after open().

Signed-off-by: Martin Kepplinger <martink@xxxxxxxxx>
---

I'm not completely sure if this patch is needed and am still investigating.
What do you think? open() could be called by the user I guess. Does
lguest_user.c depend on private_data being NULL on a first write()?


drivers/lguest/lguest_user.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 4263f4c..30251b7 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -497,6 +497,12 @@ static int close(struct inode *inode, struct file *file)
return 0;
}

+static int open(struct inode *inode, struct file *file)
+{
+ /* the miscdevice core sets private_data on open() */
+ file->private_data = NULL;
+}
+
/*L:000
* Welcome to our journey through the Launcher!
*
@@ -514,6 +520,7 @@ static int close(struct inode *inode, struct file *file)
*/
static const struct file_operations lguest_fops = {
.owner = THIS_MODULE,
+ .open = open,
.release = close,
.write = write,
.read = read,
--
1.7.10.4

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