From: Hillf Danton Date: Tue, 6 Aug 2019 08:40:15 +0000 (+0800) Subject: [RAMEN9610-21380]HID: hiddev: do cleanup in failure of opening a device X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=893e42691ad720849dc8d9a619f33685fb084732;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [RAMEN9610-21380]HID: hiddev: do cleanup in failure of opening a device commit 6d4472d7bec39917b54e4e80245784ea5d60ce49 upstream. Undo what we did for opening before releasing the memory slice. Change-Id: I0af2538257801d16761dd60e5eaeeb448e6a7aa4 Reported-by: syzbot Cc: Andrey Konovalov Signed-off-by: Hillf Danton Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 3de515c380203c6984f3d227ae26b86a88c4a6cb) --- diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 5e1361dfb61c..ce342fd0457e 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c @@ -321,6 +321,10 @@ bail_normal_power: hid_hw_power(hid, PM_HINT_NORMAL); bail_unlock: mutex_unlock(&hiddev->existancelock); + + spin_lock_irq(&list->hiddev->list_lock); + list_del(&list->node); + spin_unlock_irq(&list->hiddev->list_lock); bail: file->private_data = NULL; vfree(list);