Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 585d98e0 authored by Thomas Petazzoni's avatar Thomas Petazzoni Committed by Greg Kroah-Hartman
Browse files

char: misc: assign file->private_data in all cases



In fa1f68db ("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: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2608fb65
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -143,8 +143,8 @@ static int misc_open(struct inode * inode, struct file * file)
	err = 0;
	old_fops = file->f_op;
	file->f_op = new_fops;
	if (file->f_op->open) {
	file->private_data = c;
	if (file->f_op->open) {
		err=file->f_op->open(inode,file);
		if (err) {
			fops_put(file->f_op);