Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b545dc9d authored by Hillf Danton's avatar Hillf Danton Committed by Greg Kroah-Hartman
Browse files

HID: hiddev: do cleanup in failure of opening a device



commit 6d4472d7bec39917b54e4e80245784ea5d60ce49 upstream.

Undo what we did for opening before releasing the memory slice.

Reported-by: default avatarsyzbot <syzbot+62a1e04fd3ec2abf099e@syzkaller.appspotmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarHillf Danton <hdanton@sina.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0aab1a46
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -321,6 +321,10 @@ static int hiddev_open(struct inode *inode, struct file *file)
	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);