From: sashiko-bot@kernel.org
To: "Haojie Li" <lihaojie@kylinos.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device
Date: Tue, 25 Aug 2026 10:20:08 +0000 [thread overview]
Message-ID: <20260825102008.A37C41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825100845.438893-1-lihaojie@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] platform_device_register_data() is incorrectly used to create a shallow kmemdup copy of a 'struct device' object by value instead of passing a pointer.
--
--- Patch [1]: [PATCH v2] drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device ---
commit 7a17d0a013a729b24666cfaf3097488acb16a27b
Author: Haojie Li <lihaojie@kylinos.cn>
drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device
This commit adds an IS_ERR() check for the return value of
platform_device_register_data() when initializing the ovl_adaptor
device. This prevents a potential kernel crash caused by using an
invalid pointer if the registration fails.
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index c86a3f54f35bc..b281482ab8c82 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -1112,6 +1112,9 @@ static int mtk_drm_probe(struct platform_device *pdev)
> PLATFORM_DEVID_AUTO,
> (void *)private->mmsys_dev,
> sizeof(*private->mmsys_dev));
[Severity: High]
This isn't a bug introduced by this patch, but is it safe to pass
sizeof(*private->mmsys_dev) to platform_device_register_data() here?
The size parameter instructs platform_device_register_data() to kmemdup
the entire struct device object into the new platform device's platform_data.
Later in mtk_disp_ovl_adaptor_probe():
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c:mtk_disp_ovl_adaptor_probe() {
...
priv->mmsys_dev = pdev->dev.platform_data;
...
}
This extracts the cloned struct device object. Copying a struct device by
value duplicates its internal state (like kobjects, list heads, and locks).
If this cloned device is passed to generic device APIs, it could risk list
corruption, use-after-free, or power management state desynchronization.
Should this be passing a pointer to the device object instead of copying
the object by value?
> + if (IS_ERR(ovl_adaptor))
> + return PTR_ERR(ovl_adaptor);
> +
> private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev;
> mtk_ddp_comp_init(dev, NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR],
> DDP_COMPONENT_DRM_OVL_ADAPTOR);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825100845.438893-1-lihaojie@kylinos.cn?part=1
next prev parent reply other threads:[~2026-08-25 10:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 6:56 [PATCH] drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device Haojie Li
2026-08-19 7:07 ` sashiko-bot
2026-08-25 6:23 ` CK Hu (胡俊光)
2026-08-25 10:08 ` [PATCH v2] " Haojie Li
2026-08-25 10:20 ` sashiko-bot [this message]
2026-08-26 6:50 ` CK Hu (胡俊光)
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=20260825102008.A37C41F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lihaojie@kylinos.cn \
--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