Skip to content

Commit 976a54d

Browse files
Hanno Zullabentiss
authored andcommitted
HID: hid-bigbenff: call hid_hw_stop() in case of error
It's required to call hid_hw_stop() once hid_hw_start() was called previously, so error cases need to handle this. Also, hid_hw_close() is not necessary during removal. Signed-off-by: Hanno Zulla <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent 789a2c2 commit 976a54d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/hid/hid-bigbenff.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ static void bigben_remove(struct hid_device *hid)
305305
struct bigben_device *bigben = hid_get_drvdata(hid);
306306

307307
cancel_work_sync(&bigben->worker);
308-
hid_hw_close(hid);
309308
hid_hw_stop(hid);
310309
}
311310

@@ -350,7 +349,7 @@ static int bigben_probe(struct hid_device *hid,
350349
error = input_ff_create_memless(hidinput->input, NULL,
351350
hid_bigben_play_effect);
352351
if (error)
353-
return error;
352+
goto error_hw_stop;
354353

355354
name_sz = strlen(dev_name(&hid->dev)) + strlen(":red:bigben#") + 1;
356355

@@ -360,8 +359,10 @@ static int bigben_probe(struct hid_device *hid,
360359
sizeof(struct led_classdev) + name_sz,
361360
GFP_KERNEL
362361
);
363-
if (!led)
364-
return -ENOMEM;
362+
if (!led) {
363+
error = -ENOMEM;
364+
goto error_hw_stop;
365+
}
365366
name = (void *)(&led[1]);
366367
snprintf(name, name_sz,
367368
"%s:red:bigben%d",
@@ -375,7 +376,7 @@ static int bigben_probe(struct hid_device *hid,
375376
bigben->leds[n] = led;
376377
error = devm_led_classdev_register(&hid->dev, led);
377378
if (error)
378-
return error;
379+
goto error_hw_stop;
379380
}
380381

381382
/* initial state: LED1 is on, no rumble effect */
@@ -389,6 +390,10 @@ static int bigben_probe(struct hid_device *hid,
389390
hid_info(hid, "LED and force feedback support for BigBen gamepad\n");
390391

391392
return 0;
393+
394+
error_hw_stop:
395+
hid_hw_stop(hid);
396+
return error;
392397
}
393398

394399
static __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,

0 commit comments

Comments
 (0)