lkml.org 
[lkml]   [2019]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.2 093/123] HID: hiddev: do cleanup in failure of opening a device
    Date
    From: Hillf Danton <hdanton@sina.com>

    [ Upstream commit 6d4472d7bec39917b54e4e80245784ea5d60ce49 ]

    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: Sasha Levin <sashal@kernel.org>
    ---
    drivers/hid/usbhid/hiddev.c | 4 ++++
    1 file changed, 4 insertions(+)

    diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
    index c07df82923802..4e11cc6fc34bc 100644
    --- a/drivers/hid/usbhid/hiddev.c
    +++ b/drivers/hid/usbhid/hiddev.c
    @@ -308,6 +308,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);
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-08-14 04:16    [W:4.093 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site