lguest: explicitly set miscdevice's private_data NULL
PATCH 1/1 lguest: explicitly set miscdevice's private_data NULL
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.
--- drivers/lguest/lguest_user.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/lguest/lguest_user.c +8 -0
@@ -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,
Signature · 1 line
2.1.4
Quoted 9 lines · Martin Kepplinger
There is a proposed change to the miscdevice's behaviour on
open(). Currentlyfile->private_datastays NULL, but only because we don't have an open-entry in structfile_operations.This may change so that
private_data, more consistently, is always set to struct miscdevice, not only *if* the driver has it's ownopen()routine and fops-entry, see https://lkml.org/lkml/2014/12/4/939 and commit94e4fe2cab3d43b3ba7c3f721743006a8c9d913a
Quoted 4 lines
In short: If we rely on
file->private_databeing NULL, we should ensure it is NULL ourselves.Signed-off-by Martin Kepplinger <[email protected]>
OK, applied.
Thanks,
Rusty.
Quoted 38 lines
--- drivers/lguest/lguest_user.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/lguest/lguest_user.c +8
-0@@ -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,Signature · 7 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/