On Sat, Dec 04, 2010 at 09:22:23PM +0100, Oliver Neukum wrote:It's not just HIDIOCGVERSION. A couple of other commands (HIDIOCGFLAG/HIDIOCSFLAG) didn't check device existence in the first place either.
Am Samstag, 4. Dezember 2010, 00:16:12 schrieb Dmitry Torokhov:
Strictly speaking you'd change the semantics. Right now you can executeSince disconnect can happen at any time, we can't initializeWhy didn't you take the lock and check hiddev->exist at the beginning of
struct hid_device *hid = hiddev->hid at the beginning of ioctl
and then use it.
This change checks hiddev->exist flag while holding
the existancelock and uses hid_device only if it exists.
ioctl handler instead of pushing it down into individual command
handlers? I guess it would slow down HIDIOCGVERSION but I think we could
pay this price for code that is more clear ;)
the ioctl even if you know you are holding an fd to a disconnected device
open.
No, I do not think I would. I do not believe that the availability for
HIDIOCGVERSION on disconnected device is spelled out in API/ABI spec. We
only know that ioctl will either succeed or appropriate error code is
returned. The fact that right now HIDIOCGVERSION is available on
disconnected devices is just an implementation detail subject to change.