Re: [PATCH] char: misc: assign file->private_data in all cases
From: Thomas Petazzoni
Date: Tue Jun 25 2013 - 05:59:51 EST
Dear Greg Kroah-Hartman,
On Mon, 24 Jun 2013 15:26:42 -0700, Greg Kroah-Hartman wrote:
> > 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.
>
> Does this solve a problem with an existing misc driver? Or are you just
> trying to be "safe" for future, broken, drivers?
This problem was spotted while implementing a dummy/example misc driver
for training purposes. I am not aware of any mainline misc driver
affected by this problem, but I haven't reviewed all misc drivers.
It simply seems to make sense to implement the feature of fa1f68db6ca
("drivers: misc: pass miscdevice pointer via file private data") in a
way that also allows misc drivers that do not provide their own
->open() operation to use it.
That said, I'm not sure why you call such drivers 'broken'.
Best regards,
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
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/