linux/drivers/media/usb/dvb-usb-v2
Stefan Brüns fdfa59cd63 media: dvbsky: Avoid leaking dvb frontend
Commit 14f4eaedda ("media: dvbsky: fix driver unregister logic") fixed
a use-after-free by removing the reference to the frontend after deleting
the backing i2c device.

This has the unfortunate side effect the frontend device is never freed
in the dvb core leaving a dangling device, leading to errors when the
dvb core tries to register the frontend after e.g. a replug as reported
here: https://www.spinics.net/lists/linux-media/msg138181.html

media: dvbsky: issues with DVBSky T680CI

===
[  561.119145] sp2 8-0040: CIMaX SP2 successfully attached
[  561.119161] usb 2-3: DVB: registering adapter 0 frontend 0 (Silicon Labs
Si2168)...
[  561.119174] sysfs: cannot create duplicate filename '/class/dvb/
dvb0.frontend0'
===

The use after free happened as dvb_usbv2_disconnect calls in this order:
- dvb_usb_device::props->exit(...)
- dvb_usbv2_adapter_frontend_exit(...)
  + if (fe) dvb_unregister_frontend(fe)
  + dvb_usb_device::props->frontend_detach(...)

Moving the release of the i2c device from exit() to frontend_detach()
avoids the dangling pointer access and allows the core to unregister
the frontend.

This was originally reported for a DVBSky T680CI, but it also affects
the MyGica T230C. As all supported devices structure the registration/
unregistration identically, apply the change for all device types.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-03-19 16:42:24 -04:00
..
af9015.c media: af9015: correct some coding style issues 2018-03-21 14:16:32 -04:00
af9015.h media: af9015: convert to regmap api 2018-03-21 14:15:34 -04:00
af9035.c media: use strscpy() instead of strlcpy() 2018-09-11 13:32:17 -04:00
af9035.h [media] af9035: register it9133 tuner using platform binding 2017-01-31 10:49:42 -02:00
anysee.c media: use strscpy() instead of strlcpy() 2018-09-11 13:32:17 -04:00
anysee.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
au6610.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
au6610.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
az6007.c media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
ce6230.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
ce6230.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_usb_common.h [media] media: change email address 2016-01-25 12:01:08 -02:00
dvb_usb_core.c media: dvb: Use WARM definition from identify_state() 2018-12-03 13:26:21 -05:00
dvb_usb_urb.c [media] media: change email address 2016-01-25 12:01:08 -02:00
dvb_usb.h media: usb: fix several typos 2019-03-01 09:43:27 -05:00
dvbsky.c media: dvbsky: Avoid leaking dvb frontend 2019-03-19 16:42:24 -04:00
ec168.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
ec168.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
gl861.c media: usb: Use kmemdup instead of duplicating its function. 2018-12-03 13:27:17 -05:00
gl861.h media: dvb-usb/friio, dvb-usb-v2/gl861: decompose friio and merge with gl861 2018-07-30 08:50:25 -04:00
Kconfig media: rtl28xxu: add support for Sony CXD2837ER slave demod 2018-12-05 03:21:45 -05:00
lmedm04.c media: usb: fix several typos 2019-03-01 09:43:27 -05:00
lmedm04.h media: dvb: point to the location of the old README.dvb-usb file 2018-06-15 18:10:01 -03:00
Makefile media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
mxl111sf-demod.c media: dvb: represent min/max/step/tolerance freqs in Hz 2018-08-02 18:10:48 -04:00
mxl111sf-demod.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
mxl111sf-gpio.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-gpio.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-i2c.c media: mxl111sf: remove redundant assignment to index 2017-10-31 07:27:14 -04:00
mxl111sf-i2c.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-phy.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-phy.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-reg.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
mxl111sf-tuner.c media: dvb: convert tuner_info frequencies to Hz 2018-08-02 16:14:50 -04:00
mxl111sf-tuner.h media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
mxl111sf.c media: usb: fix several typos 2019-03-01 09:43:27 -05:00
mxl111sf.h media: mxl111sf: declare its own pads 2018-09-17 13:16:19 -04:00
rtl28xxu.c media: rtl28xxu: add support for Sony CXD2837ER slave demod 2018-12-05 03:21:45 -05:00
rtl28xxu.h media: rtl28xxu: add support for Sony CXD2837ER slave demod 2018-12-05 03:21:45 -05:00
usb_urb.c media: dvb-usb-v2: Fix incorrect use of transfer_flags URB_FREE_BUFFER 2018-12-03 13:23:24 -05:00
zd1301.c media: use strscpy() instead of strlcpy() 2018-09-11 13:32:17 -04:00