From: Pavel Skripkin <paskripkin@gmail.com>
To: mchehab@kernel.org, tomimo@ncircle.nullnet.fi, thierry.merle@free.fr
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
Pavel Skripkin <paskripkin@gmail.com>
Subject: [PATCH] media: dvb-usb: fix memory leak in cinergyt2_frontend_attach
Date: Sun, 20 Jun 2021 23:23:17 +0300 [thread overview]
Message-ID: <20210620202317.4338-1-paskripkin@gmail.com> (raw)
My local syzbot instance hit a memory leak in
cinergyt2_frontend_attach() [1].
The problem was in non-freed dvb_frontend in case of error.
If dvb_usb_generic_rw() call fails, an error will be returned from
cinergyt2_frontend_attach() [1] and num_adapters_initialized of
dvb_usb_device won't be incremented. That means dvb usb library
won't take care of freeing allocated frontend.
Fail log:
BUG: memory leak
unreferenced object 0xffff88801d9c6000 (size 2048):
comm "kworker/1:3", pid 2960, jiffies 4295150569 (age 17.150s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 54 65 72 72 61 54 65 63 ........TerraTec
2f 71 61 6e 75 20 55 53 42 32 2e 30 20 48 69 67 /qanu USB2.0 Hig
backtrace:
[<ffffffff85e169f0>] kmalloc include/linux/slab.h:556 [inline]
[<ffffffff85e169f0>] kzalloc include/linux/slab.h:686 [inline]
[<ffffffff85e169f0>] cinergyt2_fe_attach+0x40/0x110 drivers/media/usb/dvb-usb/cinergyT2-fe.c:271
[<ffffffff85e15b31>] cinergyt2_frontend_attach+0x61/0x140 drivers/media/usb/dvb-usb/cinergyT2-core.c:74 [1]
[<ffffffff85dcd71e>] dvb_usb_adapter_frontend_init+0x35e/0x5b0 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290
[<ffffffff88f98e83>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:90 [inline]
[<ffffffff88f98e83>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:184 [inline]
Fixes: 986bd1e58b18 ("V4L/DVB (9107): Alternative version of Terratec Cinergy T2
driver")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
drivers/media/usb/dvb-usb/cinergyT2-core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
index 969a7ec71dff..fb60af097535 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
@@ -79,6 +79,7 @@ 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) {
deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n");
+ kfree(adap->fe_adap[0].fe);
}
mutex_unlock(&d->data_mutex);
--
2.32.0
next reply other threads:[~2021-06-20 20:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-20 20:23 Pavel Skripkin [this message]
2021-08-11 21:54 ` [PATCH] media: dvb-usb: fix memory leak in cinergyt2_frontend_attach Sean Young
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=20210620202317.4338-1-paskripkin@gmail.com \
--to=paskripkin@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=thierry.merle@free.fr \
--cc=tomimo@ncircle.nullnet.fi \
/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).