diff options
author | Salah Triki <salah.triki@gmail.com> | 2021-07-29 03:45:12 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2021-08-20 15:22:28 +0300 |
commit | fbf42729d0e91332e8ce75a1ecce08b8a2dab9c1 (patch) | |
tree | 118a2dc7798df202c3cdcbf20d038f19e509daca /drivers/hid/hid-elo.c | |
parent | db8d3a21275c807a4047a21bde3b57d49ca55d82 (diff) | |
download | linux-fbf42729d0e91332e8ce75a1ecce08b8a2dab9c1.tar.xz |
HID: elo: update the reference count of the usb device structure
Use usb_get_dev() to increment the reference count of the usb device
structure in order to avoid releasing the structure while it is still in
use. And use usb_put_dev() to decrement the reference count and thus,
when it will be equal to 0 the structure will be released.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-elo.c')
-rw-r--r-- | drivers/hid/hid-elo.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c index 0d22713a3874..383dfda8c12f 100644 --- a/drivers/hid/hid-elo.c +++ b/drivers/hid/hid-elo.c @@ -228,13 +228,15 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct elo_priv *priv; int ret; + struct usb_device *udev; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; INIT_DELAYED_WORK(&priv->work, elo_work); - priv->usbdev = interface_to_usbdev(to_usb_interface(hdev->dev.parent)); + udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent)); + priv->usbdev = usb_get_dev(udev); hid_set_drvdata(hdev, priv); @@ -265,6 +267,8 @@ static void elo_remove(struct hid_device *hdev) { struct elo_priv *priv = hid_get_drvdata(hdev); + usb_put_dev(priv->usbdev); + hid_hw_stop(hdev); cancel_delayed_work_sync(&priv->work); kfree(priv); |