public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Pavel Skripkin <paskripkin@gmail.com>
Cc: mchehab@kernel.org, tomimo@ncircle.nullnet.fi,
	thierry.merle@free.fr, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] media: dvb-usb: fix memory leak in cinergyt2_frontend_attach
Date: Wed, 11 Aug 2021 22:54:21 +0100	[thread overview]
Message-ID: <20210811215421.GA28513@gofer.mess.org> (raw)
In-Reply-To: <20210620202317.4338-1-paskripkin@gmail.com>

On Sun, Jun 20, 2021 at 11:23:17PM +0300, Pavel Skripkin wrote:
> 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.

This issue is already fixed by:

9ad1efee086e0 media: dvd_usb: memory leak in cinergyt2_fe_attach

Thanks for reporting and making a patch though.


Sean

> 
> 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

      reply	other threads:[~2021-08-11 21:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20 20:23 [PATCH] media: dvb-usb: fix memory leak in cinergyt2_frontend_attach Pavel Skripkin
2021-08-11 21:54 ` Sean Young [this message]

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=20210811215421.GA28513@gofer.mess.org \
    --to=sean@mess.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paskripkin@gmail.com \
    --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