linux/drivers/media
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
..
cec Linux 5.11-rc6 2021-02-01 10:03:45 +01:00
common Fixes around VM_FPNMAP and follow_pfn 2021-02-22 17:45:02 -08:00
dvb-core media: dvb_frontend: Fix fall-through warnings for Clang 2021-01-27 12:55:53 +01:00
dvb-frontends media: mxl692: MaxLinear 692 ATSC demod/tuner driver 2021-02-05 23:37:59 +01:00
firewire media: firewire: fix memory leak 2020-09-27 11:29:45 +02:00
i2c media: i2c: max9271: Add MODULE_* macros 2021-02-10 22:26:04 +01:00
mc media: mc-device.c: change media_device_request_alloc to match media_ioctl_info 2020-08-29 08:15:23 +02:00
mmc media updates for v5.8-rc1 2020-06-03 20:59:38 -07:00
pci media: ipu3-cio2: Build bridge only if ACPI is enabled 2021-02-06 09:40:04 +01:00
platform Fixes around VM_FPNMAP and follow_pfn 2021-02-22 17:45:02 -08:00
radio isa: Make the remove callback for isa drivers return void 2021-01-26 07:42:27 +01:00
rc media: rc: add keymap for minix-neo remote 2021-03-11 11:59:41 +01:00
spi media: i2c/Kconfig: use sub-menus for I2C support 2020-04-16 10:34:40 +02:00
test-drivers media: vidtv: adapter->mdev was set too late 2021-02-05 23:52:58 +01:00
tuners media: qm1d1c0042: fix error return code in qm1d1c0042_init() 2021-01-27 12:59:17 +01:00
usb media: dvb-usb: Fix memory leak at error in dvb_usb_device_init() 2021-03-11 11:59:41 +01:00
v4l2-core media: Remove the legacy v4l2-clk API 2021-02-06 09:39:44 +01:00
Kconfig media: Remove superfluous dependency for MEDIA_SUPPORT_FILTER 2020-11-27 12:19:25 +01:00
Makefile media: media/test_drivers: rename to test-drivers 2020-04-16 10:38:31 +02:00