Skip to content

Commit

Permalink
HID: elo: Revert USB reference counting
Browse files Browse the repository at this point in the history
Commit 817b8b9 ("HID: elo: fix memory leak in elo_probe") introduced
memory leak on error path, but more importantly the whole USB reference
counting is not needed at all in the first place, as the driver itself
doesn't change the reference counting in any way, and the associated
usb_device is guaranteed to be kept around by USB core as long as the
driver binding exists.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: fbf4272 ("HID: elo: update the reference count of the usb device structure")
Fixes: 817b8b9 ("HID: elo: fix memory leak in elo_probe")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Jiri Kosina committed Feb 17, 2022
1 parent 0a5a587 commit ac89895
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions drivers/hid/hid-elo.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
struct elo_priv *priv;
int ret;
struct usb_device *udev;

if (!hid_is_usb(hdev))
return -EINVAL;
Expand All @@ -238,8 +237,7 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
return -ENOMEM;

INIT_DELAYED_WORK(&priv->work, elo_work);
udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
priv->usbdev = usb_get_dev(udev);
priv->usbdev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));

hid_set_drvdata(hdev, priv);

Expand All @@ -262,7 +260,6 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)

return 0;
err_free:
usb_put_dev(udev);
kfree(priv);
return ret;
}
Expand All @@ -271,8 +268,6 @@ 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);
Expand Down

0 comments on commit ac89895

Please sign in to comment.