linux/drivers/media
Matthew Leach 2a00932f08 [media] media: usbtv: prevent access to free'd resources
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>
Cc: stable@vger.kernel.org
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-12 13:31:08 -03:00
..
common [media] v4l2-tpg: ignore V4L2_DV_RGB_RANGE setting for YUV formats 2016-07-08 16:16:52 -03:00
dvb-core [media] media: dvb_ringbuffer: Add memory barriers 2016-07-09 07:57:47 -03:00
dvb-frontends [media] cxd2841er: don't expose a dvbv5 stats to userspace if not available 2016-07-08 18:57:51 -03:00
firewire [media] dvb: modify core to implement interfaces/entities at MC new gen 2016-01-11 12:18:52 -02:00
i2c [media] media/i2c: drop the last users of the ctrl core ops 2016-07-12 11:17:19 -03:00
mmc [media] siano: register media controller earlier 2015-02-26 09:10:39 -03:00
pci [media] ivtv: use v4l2_g/s_ctrl instead of the g/s_ctrl ops 2016-07-12 11:16:44 -03:00
platform [media] vivid: set V4L2_CAP_TIMEPERFRAME 2016-07-12 13:29:49 -03:00
radio [media] radio-maxiradio: fix memory leak when device is removed 2016-06-28 08:05:47 -03:00
rc [media] Convert Wideview WT220 DVB USB driver to rc-core 2016-07-09 12:10:33 -03:00
tuners [media] it913x: do not allow driver unbind 2016-07-08 17:01:23 -03:00
usb [media] media: usbtv: prevent access to free'd resources 2016-07-12 13:31:08 -03:00
v4l2-core [media] v4l2-subdev.h: remove the control subdev ops 2016-07-12 11:17:58 -03:00
cec-edid.c [media] cec-edid: add module for EDID CEC helper functions 2016-06-28 09:45:51 -03:00
Kconfig [media] cec: fix Kconfig dependency problems 2016-07-08 18:34:00 -03:00
Makefile [media] cec: fix Kconfig dependency problems 2016-07-08 18:34:00 -03:00
media-device.c [media] media: fix media devnode ioctl/syscall and unregister race 2016-06-15 17:59:28 -03:00
media-devnode.c [media] media: fix media devnode ioctl/syscall and unregister race 2016-06-15 17:59:28 -03:00
media-entity.c [media] media: change pipeline validation return error 2016-04-29 08:07:17 -03:00