linux/drivers/media/usb
Takashi Iwai 13a79f14ab media: dvb-usb: Fix memory leak at error in dvb_usb_device_init()
dvb_usb_device_init() allocates a dvb_usb_device object, but it
doesn't release the object by itself even at errors.  The object is
released in the callee side (dvb_usb_init()) in some error cases via
dvb_usb_exit() call, but it also missed the object free in other error
paths.  And, the caller (it's only dvb_usb_device_init()) doesn't seem
caring the resource management as well, hence those memories are
leaked.

This patch assures releasing the memory at the error path in
dvb_usb_device_init().  Now dvb_usb_init() frees the resources it
allocated but leaves the passed dvb_usb_device object intact.  In
turn, the dvb_usb_device object is released in dvb_usb_device_init()
instead.
We could use dvb_usb_exit() function for releasing everything in the
callee (as it was used for some error cases in the original code), but
releasing the passed object in the callee is non-intuitive and
error-prone.  So I took this approach (which is more standard in Linus
kernel code) although it ended with a bit more open codes.

Along with the change, the patch makes sure that USB intfdata is reset
and don't return the bogus pointer to the caller of
dvb_usb_device_init() at the error path, too.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2021-03-11 11:59:41 +01: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: Consolidate dmesg output 2020-11-16 10:31:10 +01:00
b2c2 media: flexcop-usb: remove needless check before usb_free_coherent() 2020-09-27 11:25:11 +02:00
cpia2 treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cx231xx media: rc: select CONFIG_BITREVERSE where needed 2021-01-27 13:18:08 +01:00
dvb-usb media: dvb-usb: Fix memory leak at error in dvb_usb_device_init() 2021-03-11 11:59:41 +01:00
dvb-usb-v2 media: usb: dvb-usb-v2: Fix fall-through warnings for Clang 2021-01-27 12:55:20 +01:00
em28xx media: em28xx: Add pid for bulk revision of Hauppauge 461eV2 2021-03-11 11:59:41 +01:00
go7007 media: Use fallthrough pseudo-keyword 2020-08-29 08:35:27 +02:00
gspca media: gspca: Fix memory leak in probe 2020-12-07 15:00:15 +01:00
hackrf Linux 5.2-rc4 2019-06-11 12:09:28 -04:00
hdpvr media: usb: hdpvr: convert to use i2c_new_client_device() 2020-04-14 11:31:48 +02:00
msi2500 media: msi2500: assign SPI bus number dynamically 2020-11-27 08:12:11 +01:00
pvrusb2 media: pvrusb2: use semicolons rather than commas to separate statements 2020-11-16 10:31:06 +01:00
pwc media: pwc: Use correct device for DMA 2021-01-12 18:23:22 +01:00
s2255 media: media/usb: rename VFL_TYPE_GRABBER to _VIDEO 2020-02-24 16:53:16 +01:00
siano media: Use fallthrough pseudo-keyword 2020-08-29 08:35:27 +02:00
stk1160 media: media/usb: rename VFL_TYPE_GRABBER to _VIDEO 2020-02-24 16:53:16 +01:00
stkwebcam media: media/usb: rename VFL_TYPE_GRABBER to _VIDEO 2020-02-24 16:53:16 +01:00
tm6000 media: tm6000: Fix memleak in tm6000_start_stream 2021-01-12 18:22:17 +01:00
ttusb-budget media: dvb-ttusb-budget: cleanup printk logic 2020-09-03 11:15:47 +02:00
ttusb-dec media: ttusb-dec: convert tasklets to use new tasklet_setup() API 2020-08-29 08:14:42 +02:00
usbtv media: usbtv: Fix refcounting mixup 2020-10-08 09:08:20 +02:00
uvc media: uvc: strncpy -> strscpy 2021-02-05 23:53:20 +01:00
zr364xx media: zr364xx: fix memory leaks in probe() 2021-01-27 14:44:13 +01:00
Kconfig media: move CEC USB drivers to a separate directory 2020-04-15 12:06:40 +02:00
Makefile media: move CEC USB drivers to a separate directory 2020-04-15 12:06:40 +02:00