mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: jackson.lee <jackson.lee@chipsnmedia.com>
To: Brandon Brnich <b-brnich@ti.com>,
	Nas Chung <nas.chung@chipsnmedia.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>
Cc: Darren Etheridge <detheridge@ti.com>
Subject: RE: [PATCH] media: chips-media: wave5: Fix Potential Probe Resource Leak
Date: Tue, 2 Dec 2025 02:06:30 +0000	[thread overview]
Message-ID: <SLXP216MB1148CE2E7ABF4280D6C27B44EDD8A@SLXP216MB1148.KORP216.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20251119213152.1442329-1-b-brnich@ti.com>

Hi Brandon


> -----Original Message-----
> From: Brandon Brnich <b-brnich@ti.com>
> Sent: Thursday, November 20, 2025 6:32 AM
> To: Nas Chung <nas.chung@chipsnmedia.com>; jackson.lee
> <jackson.lee@chipsnmedia.com>; Mauro Carvalho Chehab <mchehab@kernel.org>;
> linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; Nicolas
> Dufresne <nicolas.dufresne@collabora.com>
> Cc: Darren Etheridge <detheridge@ti.com>; Brandon Brnich <b-brnich@ti.com>
> Subject: [PATCH] media: chips-media: wave5: Fix Potential Probe Resource
> Leak
> 
> After kthread creation during probe sequence, a handful of other failures
> could occur. If this were to happen, the kthread is never explicitly
> deleted which results in a resource leak. Add explicit cleanup of this
> resource.
> 
> Signed-off-by: Brandon Brnich <b-brnich@ti.com>
> ---
> 
> I am aware that all the dev attributes would be freed since it is
> allocated using the devm_* framework. But I did not believe that this
> framework would recursively free the thread and stop the timer. These
> would just be dangling resources unable to get killed unless deliberately
> removed in the probe function.
> 
>  drivers/media/platform/chips-media/wave5/wave5-vpu.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c
> b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
> index e1715d3f43b0..f027b4ac775a 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
> @@ -339,6 +339,11 @@ static int wave5_vpu_probe(struct platform_device
> *pdev)
>  	v4l2_device_unregister(&dev->v4l2_dev);
>  err_vdi_release:
>  	wave5_vdi_release(&pdev->dev);
> +
> +	if (dev->irq < 0) {
> +		kthread_destroy_worker(dev->worker);
> +		hrtimer_cancel(&dev->hrtimer);
> +	}

I'd like to change the above to as below.
I think we have to distinguish failure between registering IRQ handler and registering v4l2_device_register.

err_irq_release:
	if (dev->irq < 0) {
		kthread_destroy_worker(dev->worker);
		hrtimer_cancel(&dev->hrtimer);
	}
err_vdi_release:

thanks
Jackson


>  err_clk_dis:
>  	clk_bulk_disable_unprepare(dev->num_clks, dev->clks);
>  err_reset_assert:
> --
> 2.34.1


  reply	other threads:[~2025-12-02  2:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 21:31 Brandon Brnich
2025-12-02  2:06 ` jackson.lee [this message]
2025-12-11 15:04   ` Nicolas Dufresne
2025-12-11 21:36     ` Brandon Brnich
2025-12-11 21:51       ` Nicolas Dufresne
2025-12-11 22:55         ` Brandon Brnich

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=SLXP216MB1148CE2E7ABF4280D6C27B44EDD8A@SLXP216MB1148.KORP216.PROD.OUTLOOK.COM \
    --to=jackson.lee@chipsnmedia.com \
    --cc=b-brnich@ti.com \
    --cc=detheridge@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nas.chung@chipsnmedia.com \
    --cc=nicolas.dufresne@collabora.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

all inboxes | Powered by JetHome®