linux/drivers/media/usb
Matthew Leach ddc35199f2 media: usbtv: prevent access to free'd resources
commit 2a00932f08 upstream.

When disconnecting the usbtv device, the sound card is unregistered
from ALSA and the snd member of the usbtv struct is set to NULL.  If
the usbtv snd_trigger work is running, this can cause a race condition
where the kernel will attempt to access free'd resources, shown in
[1].

This patch fixes the disconnection code by cancelling any snd_trigger
work before unregistering the sound card from ALSA and checking that
the snd member still exists in the work function.

[1]:
 usb 3-1.2: USB disconnect, device number 6
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
 IP: [<ffffffff81093850>] process_one_work+0x30/0x480
 PGD 405bbf067 PUD 405bbe067 PMD 0
 Call Trace:
  [<ffffffff81093ce8>] worker_thread+0x48/0x4e0
  [<ffffffff81093ca0>] ? process_one_work+0x480/0x480
  [<ffffffff81093ca0>] ? process_one_work+0x480/0x480
  [<ffffffff81099998>] kthread+0xd8/0xf0
  [<ffffffff815c73c2>] ret_from_fork+0x22/0x40
  [<ffffffff810998c0>] ? kthread_worker_fn+0x170/0x170
 ---[ end trace 0f3dac5c1a38e610 ]---

Signed-off-by: Matthew Leach <matthew@mattleach.net>
Tested-by: Peter Sutton <foxxy@foxdogstudios.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2016-08-20 18:09:18 +02:00
..
airspy media: fix airspy usb probe error path 2016-08-10 11:49:29 +02:00
as102 [media] as102: fix error return code 2015-05-01 07:00:51 -03:00
au0828 au0828: Fix dev_state handling 2016-04-20 15:42:09 +09:00
b2c2 [media] drivers: media: usb: b2c2: use usb_*_coherent() instead of pci_*_consistent() in flexcop-usb.c 2013-10-17 11:26:41 -03:00
cpia2 [media] media: remove the setting of the flag V4L2_FL_USE_FH_PRIO 2014-07-04 16:14:59 -03:00
cx231xx [media] cx231xx: fix handling cx231xx_read_i2c_data result 2015-10-03 11:32:32 -03:00
dvb-usb [media] Technisat SkyStar USB HD,(DVB-S/S2) too much URBs for arm devices 2015-08-11 14:43:23 -03:00
dvb-usb-v2 media updates for v4.4-rc1 2015-11-05 12:05:15 -08:00
em28xx [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
go7007 [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
gspca gspca: ov534/topro: prevent a division by 0 2016-03-03 15:07:14 -08:00
hackrf [media] hackrf: move RF gain ctrl enable behind module parameter 2015-12-18 15:25:29 -02:00
hdpvr [media] hdpvr: embed video_device 2015-04-02 23:36:54 -03:00
msi2500 [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
pvrusb2 [media] v4l2: replace s_mbus_fmt by set_fmt in bridge drivers 2015-05-01 09:01:16 -03:00
pwc pwc: Add USB id for Philips Spc880nc webcam 2016-04-12 09:08:42 -07:00
s2255 [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
siano [media] siano: avoid a linkedit error if !MC 2015-03-02 14:17:01 -03:00
stk1160 [media] media: videobuf2: Change queue_setup argument 2015-10-20 14:48:39 -02:00
stkwebcam [media] stk-webcam: Delete an unnecessary check before the function call "vfree" 2015-03-02 14:53:27 -03:00
tm6000 [media] cx25821, cx88, tm6000: use SNDRV_DEFAULT_ENABLE_PNP 2015-10-01 08:42:52 -03:00
ttusb-budget [media] dvb: Get rid of typedev usage for enums 2015-06-09 17:47:35 -03:00
ttusb-dec [media] dvb: get rid of enum dmx_success 2015-10-06 19:53:02 -03:00
usbtv media: usbtv: prevent access to free'd resources 2016-08-20 18:09:18 +02:00
usbvision usbvision: fix crash on detecting device with invalid configuration 2016-04-20 15:42:17 +09:00
uvc uvc: Forward compat ioctls to their handlers directly 2016-07-27 09:47:29 -07:00
zr364xx [media] usb drivers: use BUG_ON() instead of if () BUG 2015-06-09 18:30:09 -03:00
Kconfig [media] tlg2300: move to staging in preparation for removal 2014-12-16 23:21:43 -02:00
Makefile [media] tlg2300: move to staging in preparation for removal 2014-12-16 23:21:43 -02:00