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: syzbot <syzbot+62a1e04fd3ec2abf099e@syzkaller.appspotmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
CVE-2019-19527
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
Change-Id: I0a83d5492534416e519619b6c9486fea37381310
This commit is contained in:
Hillf Danton 2019-08-06 16:40:15 +08:00 committed by matteo0026
parent 17e79001c4
commit 46a15db164
1 changed files with 4 additions and 0 deletions

View File

@ -320,6 +320,10 @@ static int hiddev_open(struct inode *inode, struct file *file)
return 0;
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;
kfree(list);