Skip to content

Commit 585d98e

Browse files
tpetazzonigregkh
authored andcommitted
char: misc: assign file->private_data in all cases
In fa1f68d ("drivers: misc: pass miscdevice pointer via file private data"), the misc driver infrastructure was changed to assigned file->private_data as a pointer to the 'struct miscdevice' that corresponds to the device being opened. However, this assignment was only done when the misc driver was declaring a driver-specific ->open() operation in its file_operations. This doesn't make sense, as the driver may not necessarily have a custom ->open() operation, and might still be interested in having file->private_data properly set for use in its ->read() and write() operations. Therefore, we move the assignment of file->private_data outside of the condition that tests whether a driver-specific ->open() operation was defined. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2608fb6 commit 585d98e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ static int misc_open(struct inode * inode, struct file * file)
143143
err = 0;
144144
old_fops = file->f_op;
145145
file->f_op = new_fops;
146+
file->private_data = c;
146147
if (file->f_op->open) {
147-
file->private_data = c;
148148
err=file->f_op->open(inode,file);
149149
if (err) {
150150
fops_put(file->f_op);

0 commit comments

Comments
 (0)