From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] media: renesas: ceu: free device data if video device is unregistered
Date: Tue, 29 Sep 2026 15:16:02 +0300 [thread overview]
Message-ID: <20260929121602.GG171869@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260915135406.2423337-1-lgs201920130244@gmail.com>
On Tue, Sep 15, 2026 at 09:54:06PM +0800, Guangshuo Li wrote:
> ceu_probe() allocates ceudev, while ceu_remove() does not free it if the
> video device has not been registered.
>
> The video device is registered from the async notifier complete
> callback, and its release callback is responsible for freeing ceudev.
> If the device is removed before the notifier completes, or before video
> device registration succeeds, video_unregister_device() does not invoke
> the release callback and the ceudev allocation is leaked.
>
> Check whether the video device was registered during remove. Unregister
> it normally when registered so that its release callback handles the
> final free, otherwise free ceudev directly.
>
> This issue was found by manual code inspection.
That's hard to believe.
How have you tested this patch ?
> Fixes: 32e5a70dc8f4 ("media: platform: Add Renesas CEU driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> drivers/media/platform/renesas/renesas-ceu.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/renesas-ceu.c b/drivers/media/platform/renesas/renesas-ceu.c
> index 65f7659a9e02..5015b7837381 100644
> --- a/drivers/media/platform/renesas/renesas-ceu.c
> +++ b/drivers/media/platform/renesas/renesas-ceu.c
> @@ -1705,7 +1705,10 @@ static void ceu_remove(struct platform_device *pdev)
>
> v4l2_device_unregister(&ceudev->v4l2_dev);
>
> - video_unregister_device(&ceudev->vdev);
> + if (video_is_registered(&ceudev->vdev))
> + video_unregister_device(&ceudev->vdev);
> + else
> + kfree(ceudev);
> }
>
> static const struct dev_pm_ops ceu_pm_ops = {
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2026-09-29 12:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 13:54 Guangshuo Li
2026-09-29 12:16 ` Laurent Pinchart [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=20260929121602.GG171869@killaraus.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hverkuil@kernel.org \
--cc=jacopo@jmondi.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
/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®