linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Dongliang Mu <mudongliangabcd@gmail.com>,
	syzbot+e1de8986786b3722050e@syzkaller.appspotmail.com,
	Sean Young <sean@mess.org>,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 16/25] media: dvd_usb: memory leak in cinergyt2_fe_attach
Date: Sun,  4 Jul 2021 19:11:14 -0400	[thread overview]
Message-ID: <20210704231123.1491517-16-sashal@kernel.org> (raw)
In-Reply-To: <20210704231123.1491517-1-sashal@kernel.org>

From: Dongliang Mu <mudongliangabcd@gmail.com>

[ Upstream commit 9ad1efee086e0e913914fa2b2173efb830bad68c ]

When the driver fails to talk with the hardware with dvb_usb_generic_rw,
it will return an error to dvb_usb_adapter_frontend_init. However, the
driver forgets to free the resource (e.g., struct cinergyt2_fe_state),
which leads to a memory leak.

Fix this by freeing struct cinergyt2_fe_state when dvb_usb_generic_rw
fails in cinergyt2_frontend_attach.

backtrace:
  [<0000000056e17b1a>] kmalloc include/linux/slab.h:552 [inline]
  [<0000000056e17b1a>] kzalloc include/linux/slab.h:682 [inline]
  [<0000000056e17b1a>] cinergyt2_fe_attach+0x21/0x80 drivers/media/usb/dvb-usb/cinergyT2-fe.c:271
  [<00000000ae0b1711>] cinergyt2_frontend_attach+0x21/0x70 drivers/media/usb/dvb-usb/cinergyT2-core.c:74
  [<00000000d0254861>] dvb_usb_adapter_frontend_init+0x11b/0x1b0 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290
  [<0000000002e08ac6>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:84 [inline]
  [<0000000002e08ac6>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:173 [inline]
  [<0000000002e08ac6>] dvb_usb_device_init.cold+0x4d0/0x6ae drivers/media/usb/dvb-usb/dvb-usb-init.c:287

Reported-by: syzbot+e1de8986786b3722050e@syzkaller.appspotmail.com
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>
---
 drivers/media/usb/dvb-usb/cinergyT2-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
index 6131aa7914a9..fb59dda7547a 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
@@ -88,6 +88,8 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
 
 	ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0);
 	if (ret < 0) {
+		if (adap->fe_adap[0].fe)
+			adap->fe_adap[0].fe->ops.release(adap->fe_adap[0].fe);
 		deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n");
 	}
 	mutex_unlock(&d->data_mutex);
-- 
2.30.2


  parent reply	other threads:[~2021-07-04 23:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-04 23:10 [PATCH AUTOSEL 4.14 01/25] spi: Make of_register_spi_device also set the fwnode Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 02/25] media: sh_vou: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 03/25] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 04/25] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 05/25] spi: omap-100k: Fix the length judgment problem Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 06/25] crypto: nx - add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 07/25] media: cpia2: fix memory leak in cpia2_usb_probe Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 08/25] media: cobalt: fix race condition in setting HPD Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 09/25] media: pvrusb2: fix warning in pvr2_i2c_core_done Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 10/25] crypto: qat - check return code of qat_hal_rd_rel_reg() Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 11/25] crypto: qat - remove unused macro in FW loader Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 12/25] media: em28xx: Fix possible memory leak of em28xx struct Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 13/25] media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 14/25] media: bt8xx: Fix a missing check bug in bt878_probe Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 15/25] media: st-hva: Fix potential NULL pointer dereferences Sasha Levin
2021-07-04 23:11 ` Sasha Levin [this message]
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 17/25] mmc: via-sdmmc: add a check against NULL pointer dereference Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 18/25] crypto: shash - avoid comparing pointers to exported functions under CFI Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 19/25] media: dvb_net: avoid speculation from net slot Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 20/25] media: siano: fix device register error path Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 21/25] btrfs: fix error handling in __btrfs_update_delayed_inode Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 22/25] btrfs: abort transaction if we fail to update the delayed inode Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 23/25] btrfs: make Private2 lifespan more consistent Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 24/25] btrfs: disable build on platforms having page size 256K Sasha Levin
2021-07-04 23:11 ` [PATCH AUTOSEL 4.14 25/25] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210704231123.1491517-16-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mudongliangabcd@gmail.com \
    --cc=sean@mess.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+e1de8986786b3722050e@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).