Skip to content

Commit 0ccdd9e

Browse files
bentissJiri Kosina
authored andcommitted
HID: lenovo-tpkbd: fix leak if tpkbd_probe_tp fails
If tpkbd_probe_tp() bails out, the probe() function return an error, but hid_hw_stop() is never called. fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1003998 Cc: [email protected] Signed-off-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 8821f5d commit 0ccdd9e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/hid/hid-lenovo-tpkbd.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,27 @@ static int tpkbd_probe(struct hid_device *hdev,
414414
ret = hid_parse(hdev);
415415
if (ret) {
416416
hid_err(hdev, "hid_parse failed\n");
417-
goto err_free;
417+
goto err;
418418
}
419419

420420
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
421421
if (ret) {
422422
hid_err(hdev, "hid_hw_start failed\n");
423-
goto err_free;
423+
goto err;
424424
}
425425

426426
uhdev = (struct usbhid_device *) hdev->driver_data;
427427

428-
if (uhdev->ifnum == 1)
429-
return tpkbd_probe_tp(hdev);
428+
if (uhdev->ifnum == 1) {
429+
ret = tpkbd_probe_tp(hdev);
430+
if (ret)
431+
goto err_hid;
432+
}
430433

431434
return 0;
432-
err_free:
435+
err_hid:
436+
hid_hw_stop(hdev);
437+
err:
433438
return ret;
434439
}
435440

0 commit comments

Comments
 (0)