media: cpia2_usb: first wake up, then free in disconnect
authorOliver Neukum <oneukum@suse.com>
Thu, 9 May 2019 08:57:09 +0000 (04:57 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Aug 2019 07:33:44 +0000 (09:33 +0200)
commit0b8a71a8bd2129ca9cc115195fd9630564765772
tree9b6d140b0f589c25faca8175d99fa28c8ee9b5c3
parentf7d3edb053435ac79b2ee9bd89d18cb2d43e0d5d
media: cpia2_usb: first wake up, then free in disconnect

commit eff73de2b1600ad8230692f00bc0ab49b166512a upstream.

Kasan reported a use after free in cpia2_usb_disconnect()
It first freed everything and then woke up those waiting.
The reverse order is correct.

Fixes: 6c493f8b28c67 ("[media] cpia2: major overhaul to get it in a working state again")

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: syzbot+0c90fc937c84f97d0aa6@syzkaller.appspotmail.com
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/cpia2/cpia2_usb.c