]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
HID: hiddev: fix mess in hiddev_open()
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 17 Dec 2019 22:50:21 +0000 (14:50 -0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
commit6c413bc2b974b0ee1706ae79d14e903e284f3a2b
tree953110381d0cf8db3166bd5c71e0e10e23d5631d
parent92d96682b7387aa66cfce5429a1bcb7e1da896a4
HID: hiddev: fix mess in hiddev_open()

BugLink: https://bugs.launchpad.net/bugs/1861934
commit 18a1b06e5b91d47dc86c0a66a762646ea7c5d141 upstream.

The open method of hiddev handler fails to bring the device out of
autosuspend state as was promised in 0361a28d3f9a, as it actually has 2
blocks that try to start the transport (call hid_hw_open()) with both
being guarded by the "open" counter, so the 2nd block is never executed as
the first block increments the counter so it is never at 0 when we check
it for the second block.

Additionally hiddev_open() was leaving counter incremented on errors,
causing the device to never be reopened properly if there was ever an
error.

Let's fix all of this by factoring out code that creates client structure
and powers up the device into a separate function that is being called
from usbhid_open() with the "existancelock" being held.

Fixes: 0361a28d3f9a ("HID: autosuspend support for USB HID")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/hid/usbhid/hiddev.c