Skip to content

Commit ac89895

Browse files
author
Jiri Kosina
committed
HID: elo: Revert USB reference counting
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> 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 <[email protected]>
1 parent 0a5a587 commit ac89895

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

drivers/hid/hid-elo.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
228228
{
229229
struct elo_priv *priv;
230230
int ret;
231-
struct usb_device *udev;
232231

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

240239
INIT_DELAYED_WORK(&priv->work, elo_work);
241-
udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
242-
priv->usbdev = usb_get_dev(udev);
240+
priv->usbdev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
243241

244242
hid_set_drvdata(hdev, priv);
245243

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

263261
return 0;
264262
err_free:
265-
usb_put_dev(udev);
266263
kfree(priv);
267264
return ret;
268265
}
@@ -271,8 +268,6 @@ static void elo_remove(struct hid_device *hdev)
271268
{
272269
struct elo_priv *priv = hid_get_drvdata(hdev);
273270

274-
usb_put_dev(priv->usbdev);
275-
276271
hid_hw_stop(hdev);
277272
cancel_delayed_work_sync(&priv->work);
278273
kfree(priv);

0 commit comments

Comments
 (0)