--- x/drivers/hid/hid-steam.c +++ y/drivers/hid/hid-steam.c @@ -313,6 +313,7 @@ struct steam_device { u16 rumble_left; u16 rumble_right; unsigned int sensor_timestamp_us; + unsigned int dead; struct work_struct unregister_work; }; @@ -618,6 +619,8 @@ static void steam_input_close(struct inp unsigned long flags; bool set_lizard_mode; + if (dev->going_away) + return; if (!(steam->quirks & STEAM_QUIRK_DECK)) { spin_lock_irqsave(&steam->lock, flags); set_lizard_mode = !steam->client_opened && lizard_mode; @@ -1140,6 +1143,10 @@ static int steam_client_ll_open(struct h unsigned long flags; spin_lock_irqsave(&steam->lock, flags); + if (steam->dead) { + spin_unlock_irqrestore(&steam->lock, flags); + return -ENODEV; + } steam->client_opened++; spin_unlock_irqrestore(&steam->lock, flags); @@ -1156,6 +1163,10 @@ static void steam_client_ll_close(struct bool connected; spin_lock_irqsave(&steam->lock, flags); + if (steam->dead) { + spin_unlock_irqrestore(&steam->lock, flags); + return; + } steam->client_opened--; connected = steam->connected && !steam->client_opened; spin_unlock_irqrestore(&steam->lock, flags); @@ -1321,11 +1332,15 @@ err_cancel_work: static void steam_remove(struct hid_device *hdev) { struct steam_device *steam = hid_get_drvdata(hdev); + unsigned long flags; if (!steam || hdev->group == HID_GROUP_STEAM) { hid_hw_stop(hdev); return; } + spin_lock_irqsave(&steam->lock, flags); + steam->dead++; + spin_unlock_irqrestore(&steam->lock, flags); cancel_delayed_work_sync(&steam->mode_switch); cancel_work_sync(&steam->work_connect); @@ -1350,6 +1365,8 @@ static void steam_do_connect_event(struc spin_lock_irqsave(&steam->lock, flags); changed = steam->connected != connected; steam->connected = connected; + if (steam->dead) + changed = false; spin_unlock_irqrestore(&steam->lock, flags); if (changed && schedule_work(&steam->work_connect) == 0)