linux/drivers/media
Matthew Leach d5dec66819 [media] media: usbtv: prevent access to free'd resources
[ Upstream commit 2a00932f08 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
History 2016-08-22 12:23:07 -04:00
..
common [media] saa7146: Create a device name before it's used 2014-10-21 08:51:44 -02:00
dvb-core [media] media: dvb_ringbuffer: Add memory barriers 2016-08-22 12:23:05 -04:00
dvb-frontends [media] tda1004x: only update the frontend properties if locked 2016-02-15 15:42:40 -05:00
firewire [media] firewire: firedtv-avc: fix more potential buffer overflow 2014-09-23 16:13:39 -03:00
i2c [media] adv7511: TX_EDID_PRESENT is still 1 after a disconnect 2016-04-18 08:49:16 -04:00
mmc [media] siano: get rid of CammelCase from smscoreapi.h 2013-03-21 10:03:16 -03:00
parport [media] pms: Fix a bad usage of the stack 2014-09-26 06:47:55 -03:00
pci [media] bttv: Width must be a multiple of 16 when capturing planar formats 2016-04-18 08:49:20 -04:00
platform s5p-mfc: Add release callback for memory region devs 2016-08-22 12:22:57 -04:00
radio [media] wl128x: fix fmdbg compiler warning 2014-10-24 09:27:34 -02:00
rc [media] Fix RC5 decoding with Fintek CIR chipset 2016-08-22 12:23:06 -04:00
tuners [media] si2157: return -EINVAL if firmware blob is too big 2016-04-13 20:44:38 -04:00
usb [media] media: usbtv: prevent access to free'd resources 2016-08-22 12:23:07 -04:00
v4l2-core [media] media: v4l2-compat-ioctl32: fix missing length copy in put_v4l2_buffer32 2016-04-12 09:10:09 -04:00
Kconfig [media] Kconfig: do not select SPI bus on sub-driver auto-select 2014-09-04 12:18:49 -03:00
Makefile [media] move i2c files into drivers/media/i2c 2012-09-06 18:42:54 -03:00
media-device.c [media] media: Use strlcpy instead of custom code 2014-09-21 20:27:08 -03:00
media-devnode.c [media] media-devnode: just return 0 instead of using a var 2014-09-03 17:59:28 -03:00
media-entity.c [media] media: Check for active links on pads with MEDIA_PAD_FL_MUST_CONNECT flag 2013-12-04 15:03:45 -02:00