linux/drivers/media/usb/em28xx
Dongliang Mu 6fa54bc713 media: em28xx-input: fix refcount bug in em28xx_usb_disconnect
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: ac56886371 ("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>
2021-08-04 14:43:49 +02:00
..
em28xx-audio.c media: em28xx-audio: use semicolons rather than commas to separate statements 2020-11-16 10:31:06 +01:00
em28xx-camera.c
em28xx-cards.c media: drivers/media/usb/em28xx/em28xx-cards.c : fix typo issues 2021-06-02 14:05:26 +02:00
em28xx-core.c media: em28xx-core: Fix TS2 active led 2021-02-05 23:38:31 +01:00
em28xx-dvb.c media: em28xx: fix memory leak 2021-04-06 10:36:58 +02:00
em28xx-i2c.c media: em28xx-core: Fix i2c error debug 2021-02-05 23:39:04 +01:00
em28xx-input.c media: em28xx-input: fix refcount bug in em28xx_usb_disconnect 2021-08-04 14:43:49 +02:00
em28xx-reg.h
em28xx-v4l.h
em28xx-vbi.c
em28xx-video.c media: media/usb: rename VFL_TYPE_GRABBER to _VIDEO 2020-02-24 16:53:16 +01:00
em28xx.h media: em28xx/em28xx.h: Remove duplicate struct declaration 2021-04-06 16:11:54 +02:00
Kconfig media: em28xx: Add support for Hauppauge USB QuadHD 2021-02-05 23:40:15 +01:00
Makefile media: prefix header search paths with $(srctree)/ 2019-05-18 11:49:56 +09:00