Skip to content

Commit e53fc23

Browse files
endriftJiri Kosina
authored andcommitted
HID: hid-steam: Fix use-after-free when detaching device
When a hid-steam device is removed it must clean up the client_hdev used for intercepting hidraw access. This can lead to scheduling deferred work to reattach the input device. Though the cleanup cancels the deferred work, this was done before the client_hdev itself is cleaned up, so it gets rescheduled. This patch fixes the ordering to make sure the deferred work is properly canceled. Reported-by: syzbot+0154da2d403396b2bd59@syzkaller.appspotmail.com Fixes: 7950424 ("HID: hid-steam: Move hidraw input (un)registering to work") Signed-off-by: Vicki Pfau <vi@endrift.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent a6a4f4e commit e53fc23

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/hid-steam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,11 +1327,11 @@ static void steam_remove(struct hid_device *hdev)
13271327
return;
13281328
}
13291329

1330+
hid_destroy_device(steam->client_hdev);
13301331
cancel_delayed_work_sync(&steam->mode_switch);
13311332
cancel_work_sync(&steam->work_connect);
13321333
cancel_work_sync(&steam->rumble_work);
13331334
cancel_work_sync(&steam->unregister_work);
1334-
hid_destroy_device(steam->client_hdev);
13351335
steam->client_hdev = NULL;
13361336
steam->client_opened = 0;
13371337
if (steam->quirks & STEAM_QUIRK_WIRELESS) {

0 commit comments

Comments
 (0)