Skip to content

Commit 7998193

Browse files
committed
HID: sony: fix error path in probe
When the setup of the GHL fails, we are not calling hid_hw_stop(). This leads to the hidraw node not being released, meaning a crash whenever somebody attempts to open the file. Cc: [email protected] Signed-off-by: Benjamin Tissoires <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f237d90 commit 7998193

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/hid/hid-sony.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,19 +3037,23 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
30373037
*/
30383038
if (!(hdev->claimed & HID_CLAIMED_INPUT)) {
30393039
hid_err(hdev, "failed to claim input\n");
3040-
hid_hw_stop(hdev);
3041-
return -ENODEV;
3040+
ret = -ENODEV;
3041+
goto err;
30423042
}
30433043

30443044
if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
3045-
if (!hid_is_usb(hdev))
3046-
return -EINVAL;
3045+
if (!hid_is_usb(hdev)) {
3046+
ret = -EINVAL;
3047+
goto err;
3048+
}
30473049

30483050
usbdev = to_usb_device(sc->hdev->dev.parent->parent);
30493051

30503052
sc->ghl_urb = usb_alloc_urb(0, GFP_ATOMIC);
3051-
if (!sc->ghl_urb)
3052-
return -ENOMEM;
3053+
if (!sc->ghl_urb) {
3054+
ret = -ENOMEM;
3055+
goto err;
3056+
}
30533057

30543058
if (sc->quirks & GHL_GUITAR_PS3WIIU)
30553059
ret = ghl_init_urb(sc, usbdev, ghl_ps3wiiu_magic_data,
@@ -3059,7 +3063,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
30593063
ARRAY_SIZE(ghl_ps4_magic_data));
30603064
if (ret) {
30613065
hid_err(hdev, "error preparing URB\n");
3062-
return ret;
3066+
goto err;
30633067
}
30643068

30653069
timer_setup(&sc->ghl_poke_timer, ghl_magic_poke, 0);
@@ -3068,6 +3072,10 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
30683072
}
30693073

30703074
return ret;
3075+
3076+
err:
3077+
hid_hw_stop(hdev);
3078+
return ret;
30713079
}
30723080

30733081
static void sony_remove(struct hid_device *hdev)

0 commit comments

Comments
 (0)