linux-brain/drivers/media/usb
Dongliang Mu d2ea2f0725 media: em28xx-input: fix refcount bug in em28xx_usb_disconnect
[ Upstream commit 6fa54bc713c262e1cfbc5613377ef52280d7311f ]

If em28xx_ir_init fails, it would decrease the refcount of dev. However,
in the em28xx_ir_fini, when ir is NULL, it goes to ref_put and decrease
the refcount of dev. This will lead to a refcount bug.

Fix this bug by removing the kref_put in the error handling code
of em28xx_ir_init.

refcount_t: underflow; use-after-free.
WARNING: CPU: 0 PID: 7 at lib/refcount.c:28 refcount_warn_saturate+0x18e/0x1a0 lib/refcount.c:28
Modules linked in:
CPU: 0 PID: 7 Comm: kworker/0:1 Not tainted 5.13.0 #3
Workqueue: usb_hub_wq hub_event
RIP: 0010:refcount_warn_saturate+0x18e/0x1a0 lib/refcount.c:28
Call Trace:
  kref_put.constprop.0+0x60/0x85 include/linux/kref.h:69
  em28xx_usb_disconnect.cold+0xd7/0xdc drivers/media/usb/em28xx/em28xx-cards.c:4150
  usb_unbind_interface+0xbf/0x3a0 drivers/usb/core/driver.c:458
  __device_release_driver drivers/base/dd.c:1201 [inline]
  device_release_driver_internal+0x22a/0x230 drivers/base/dd.c:1232
  bus_remove_device+0x108/0x160 drivers/base/bus.c:529
  device_del+0x1fe/0x510 drivers/base/core.c:3540
  usb_disable_device+0xd1/0x1d0 drivers/usb/core/message.c:1419
  usb_disconnect+0x109/0x330 drivers/usb/core/hub.c:2221
  hub_port_connect drivers/usb/core/hub.c:5151 [inline]
  hub_port_connect_change drivers/usb/core/hub.c:5440 [inline]
  port_event drivers/usb/core/hub.c:5586 [inline]
  hub_event+0xf81/0x1d40 drivers/usb/core/hub.c:5668
  process_one_work+0x2c9/0x610 kernel/workqueue.c:2276
  process_scheduled_works kernel/workqueue.c:2338 [inline]
  worker_thread+0x333/0x5b0 kernel/workqueue.c:2424
  kthread+0x188/0x1d0 kernel/kthread.c:319
  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Reported-by: Dongliang Mu <mudongliangabcd@gmail.com>
Fixes: ac5688637144 ("media: em28xx: Fix possible memory leak of em28xx struct")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-09-15 09:47:33 +02:00
..
airspy media: media/usb: don't set description in ENUM_FMT 2019-07-22 14:01:05 -04:00
as102 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
au0828 media: au0828: fix a NULL vs IS_ERR() check 2021-07-14 16:53:21 +02:00
b2c2 media: flexcop-usb: fix endpoint sanity check 2020-04-01 11:02:15 +02:00
cpia2 media: cpia2: fix memory leak in cpia2_usb_probe 2021-07-14 16:53:11 +02:00
cx231xx media: usb: cx231xx-417: fix a memory leak bug 2019-08-26 10:40:17 -03:00
dvb-usb media: dvb-usb: Fix error handling in dvb_usb_i2c_init 2021-09-15 09:47:31 +02:00
dvb-usb-v2 media: rtl28xxu: fix zero-length control request 2021-08-12 13:21:01 +02:00
em28xx media: em28xx-input: fix refcount bug in em28xx_usb_disconnect 2021-09-15 09:47:33 +02:00
go7007 media: go7007: remove redundant initialization 2021-09-15 09:47:31 +02:00
gspca media: gspca/sunplus: fix zero-length control requests 2021-07-19 08:53:18 +02:00
hackrf Linux 5.2-rc4 2019-06-11 12:09:28 -04:00
hdpvr media: hdpvr: remove redundant assignment to retval 2019-08-26 10:43:53 -03:00
msi2500 media: msi2500: assign SPI bus number dynamically 2020-12-30 11:51:00 +01:00
pulse8-cec media: pulse8-cec: fix lost cec_transmit_attempt_done() call 2020-01-09 10:19:56 +01:00
pvrusb2 media: pvrusb2: fix warning in pvr2_i2c_core_done 2021-07-14 16:53:11 +02:00
pwc media: pwc: Use correct device for DMA 2021-02-23 15:02:26 +01:00
rainshadow-cec treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 55 2019-05-24 17:36:42 +02:00
s2255 media: drivers/media: don't set pix->priv = 0 2019-07-23 08:48:33 -04:00
siano USB fixes for 5.2-rc3 2019-05-31 08:16:31 -07:00
stk1160 media: media/usb: don't set description in ENUM_FMT 2019-07-22 14:01:05 -04:00
stkwebcam media: stkwebcam: fix memory leak in stk_camera_probe 2021-09-12 08:56:40 +02:00
tm6000 media: tm6000: Fix memleak in tm6000_start_stream 2021-03-04 10:26:21 +01:00
ttusb-budget treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ttusb-dec media: ttusb-dec: Fix info-leak in ttusb_dec_send_command() 2019-08-21 18:39:55 -03:00
usbtv media: usbtv: Fix deadlock on suspend 2021-03-17 17:03:39 +01:00
usbvision media: usbvision: Fix races among open, close, and disconnect 2019-11-29 10:10:06 +01:00
uvc media: uvcvideo: Fix pixel format change for Elgato Cam Link 4K 2021-07-19 08:53:18 +02:00
zr364xx media: drivers/media/usb: fix memory leak in zr364xx_probe 2021-08-26 08:36:12 -04:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00