From: sashiko-bot@kernel.org
To: "Guangshuo Li" <lgs201920130244@gmail.com>
Cc: linux-amlogic@lists.infradead.org, neil.armstrong@linaro.org
Subject: Re: [PATCH] media: meson: vdec: avoid double free on video register failure
Date: Mon, 18 May 2026 06:10:04 +0000 [thread overview]
Message-ID: <20260518061005.B9EB4C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260518054318.979147-1-lgs201920130244@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Bypassing kobject lifetime management via a dummy release function creates a Use-After-Free (UAF) vulnerability.
--
commit c9bf433f66378b70af4be79f5c3eedbee4a4582b
Author: Guangshuo Li <lgs201920130244@gmail.com>
media: meson: vdec: avoid double free on video register failure
This commit temporarily sets the video device release function to
video_device_release_empty before calling video_register_device() to prevent
a double-free on failure. It restores the original release function upon
success.
> diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
> index 4b77ec1af5a76..2994e46cbc259 100644
> --- a/drivers/staging/media/meson/vdec/vdec.c
> +++ b/drivers/staging/media/meson/vdec/vdec.c
> @@ -1074,7 +1074,7 @@ static int vdec_probe(struct platform_device *pdev)
> mutex_init(&core->lock);
>
> strscpy(vdev->name, "meson-video-decoder", sizeof(vdev->name));
> - vdev->release = video_device_release;
> + vdev->release = video_device_release_empty;
> vdev->fops = &vdec_fops;
> vdev->ioctl_ops = &vdec_ioctl_ops;
> vdev->vfl_dir = VFL_DIR_M2M;
> @@ -1089,6 +1089,7 @@ static int vdec_probe(struct platform_device *pdev)
> dev_err(dev, "Failed registering video device\n");
> goto err_vdev_release;
When video_register_device() invokes device_register(), the embedded struct
device is initialized and can potentially be exposed to the system via
sysfs.
If registration fails, put_device() is called to drop the reference, but
this does not guarantee immediate synchronous destruction. Concurrent
subsystems might temporarily hold references, or if
CONFIG_DEBUG_KOBJECT_RELEASE is enabled, the kobject release is scheduled
on a workqueue.
Will bypassing the kobject lifetime management here by setting a dummy
release function and synchronously freeing the device in err_vdev_release
lead to a use-after-free?
Once the delayed kobject cleanup runs or concurrent holders drop their
references, the kernel could access the already-freed struct device within
the freed vdev to perform internal kobject teardown.
> }
> + vdev->release = video_device_release;
>
> return 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518054318.979147-1-lgs201920130244@gmail.com?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
prev parent reply other threads:[~2026-05-18 6:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 5:43 [PATCH] media: meson: vdec: avoid double free on video register failure Guangshuo Li
2026-05-18 6:10 ` sashiko-bot [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=20260518061005.B9EB4C2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=sashiko-reviews@lists.linux.dev \
/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