Skip to content

Commit 2e59224

Browse files
matrix-wskJiri Kosina
authored andcommitted
HID: replace BUG_ON() with WARN_ON()
There is no need to kill the system entirely in HID with BUG_ON, use WARN_ON to handle fault more gracefully which allow the system to keep running. Signed-off-by: He Lugang <helugang@uniontech.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 6485cf5 commit 2e59224

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/hid/hid-cp2112.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ static int cp2112_set_usb_config(struct hid_device *hdev,
852852
{
853853
int ret;
854854

855-
BUG_ON(cfg->report != CP2112_USB_CONFIG);
855+
if (WARN_ON(cfg->report != CP2112_USB_CONFIG))
856+
return -EINVAL;
856857

857858
ret = cp2112_hid_output(hdev, (u8 *)cfg, sizeof(*cfg),
858859
HID_FEATURE_REPORT);

drivers/hid/hid-lg4ff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,8 @@ int lg4ff_init(struct hid_device *hid)
13501350

13511351
/* Initialize device properties */
13521352
if (mmode_ret == LG4FF_MMODE_IS_MULTIMODE) {
1353-
BUG_ON(mmode_idx == -1);
1353+
if (WARN_ON(mmode_idx == -1))
1354+
return -EINVAL;
13541355
mmode_wheel = &lg4ff_multimode_wheels[mmode_idx];
13551356
}
13561357
lg4ff_init_wheel_data(&entry->wdata, &lg4ff_devices[i], mmode_wheel, real_product_id);

drivers/hid/hid-sony.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,8 @@ static int sony_leds_init(struct sony_sc *sc)
13791379
u8 max_brightness[MAX_LEDS] = { [0 ... (MAX_LEDS - 1)] = 1 };
13801380
u8 use_hw_blink[MAX_LEDS] = { 0 };
13811381

1382-
BUG_ON(!(sc->quirks & SONY_LED_SUPPORT));
1382+
if (WARN_ON(!(sc->quirks & SONY_LED_SUPPORT)))
1383+
return -EINVAL;
13831384

13841385
if (sc->quirks & BUZZ_CONTROLLER) {
13851386
sc->led_count = 4;

0 commit comments

Comments
 (0)