lguest: explicitly set miscdevice's private_data NULL
authorMartin Kepplinger <martink@posteo.de>
Tue, 24 Mar 2015 01:21:20 +0000 (11:51 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 24 Mar 2015 01:22:06 +0000 (11:52 +1030)
There is a proposed change to the miscdevice's behaviour on open(). Currently
file->private_data stays NULL, but only because we don't have an open-entry in
struct file_operations.

This may change so that private_data, more consistently, is always set to
struct miscdevice, not only *if* the driver has it's own open() routine and
fops-entry, see https://lkml.org/lkml/2014/12/4/939 and commit
94e4fe2cab3d43b3ba7c3f721743006a8c9d913a

In short: If we rely on file->private_data being NULL, we should ensure
it is NULL ourselves.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/lguest/lguest_user.c

index c4c6113eb9a617a95f684ffa45ac87386b289095..30c60687d277c47efb20ea0a1bba4826444af09d 100644 (file)
@@ -339,6 +339,13 @@ static ssize_t write(struct file *file, const char __user *in,
        }
 }
 
+static int open(struct inode *inode, struct file *file)
+{
+       file->private_data = NULL;
+
+       return 0;
+}
+
 /*L:060
  * The final piece of interface code is the close() routine.  It reverses
  * everything done in initialize().  This is usually called because the
@@ -409,6 +416,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,
This page took 0.025498 seconds and 5 git commands to generate.