From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: linux-sunxi@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 6/11] drm: ingenic: Use devm_of_reserved_mem_device_init()
Date: Wed, 02 Sep 2026 20:27:27 +0000 [thread overview]
Message-ID: <20260902202727.B4CE71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902201640.2024648-7-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Using devres (`devm_*`) allocations in a component bind callback causes resource leaks and rebind failures.
- [High] Hardware clocks are disabled before shutting down the DRM pipeline, causing a bus hang on unbind.
- [High] `component_unbind_all()` is executed from a devres cleanup action without holding `component_mutex`, triggering a kernel warning and data race.
--
commit c7a21593821addf1c793b56266b4eca7b14e1ad2
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
drm: ingenic: Use devm_of_reserved_mem_device_init()
Replace the hand-rolled devm wrapper (ingenic_drm_release_rmem +
devm_add_action_or_reset) with the standard
devm_of_reserved_mem_device_init(), letting the device resource
manager handle cleanup automatically.
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index 738a80b2550ff..2c4dd6ed2d413 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -1060,11 +1060,6 @@ static void ingenic_drm_unbind_all(void *d)
> component_unbind_all(priv->dev, &priv->drm);
> }
[Severity: High]
This isn't a bug introduced by this patch, but is component_unbind_all()
executed from a devres cleanup action without holding component_mutex?
The driver registers ingenic_drm_unbind_all() as a devres action via
devm_add_action_or_reset(). When the platform device is removed, the driver
core executes devres cleanup actions after ->remove() returns.
At this point, the component framework is inactive and component_mutex is not
held, but ingenic_drm_unbind_all() directly calls component_unbind_all(),
which strictly requires this mutex.
Could this trigger a kernel warning (WARN_ON(!mutex_is_locked(&component_mutex))),
and potential list corruption or use-after-free due to concurrent modification
of the component lists without proper serialization?
[ ... ]
> @@ -1127,16 +1122,10 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
> }
>
> if (IS_ENABLED(CONFIG_OF_RESERVED_MEM)) {
> - ret = of_reserved_mem_device_init(dev);
> + ret = devm_of_reserved_mem_device_init(dev);
>
> if (ret && ret != -ENODEV)
> dev_warn(dev, "Failed to get reserved memory: %d\n", ret);
> -
> - if (!ret) {
> - ret = devm_add_action_or_reset(dev, ingenic_drm_release_rmem, dev);
> - if (ret)
> - return ret;
> - }
> }
>
> priv = devm_drm_dev_alloc(dev, &ingenic_drm_driver_data,
[Severity: High]
This is a pre-existing issue, but does using devres (devm_*) allocations in a
component bind callback cause resource leaks and rebind failures?
When the component framework unbinds a device (e.g., if the IPU component is
removed), ingenic_drm_unbind() is called, but it does not trigger devres cleanup
since devres is tied to the platform device, not the component.
When it binds again, ingenic_drm_bind() runs, leaking previous devres
allocations like devm_drm_dev_alloc(). This also causes failures when requesting
exclusive resources again, such as:
ingenic_drm_bind()
...
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
This will fail on rebind because the MMIO region remains held by the leaked
previous allocation. Can this be triggered locally by a privileged user
unbinding the IPU component or the display driver via sysfs?
While reviewing this file, I noticed another pre-existing issue:
[Severity: High]
This isn't a bug introduced by this patch, but are hardware clocks disabled
before shutting down the DRM pipeline, causing a bus hang on unbind?
In ingenic_drm_unbind():
clk_disable_unprepare(priv->pix_clk);
drm_dev_unregister(&priv->drm);
drm_atomic_helper_shutdown(&priv->drm);
When the driver is unbound while the display is active, it first disables
lcd_clk and pix_clk. Immediately after, it calls drm_atomic_helper_shutdown(),
which iterates over active CRTCs and planes to disable them.
These disable callbacks (like ingenic_drm_bridge_atomic_disable() and
ingenic_drm_plane_disable()) perform MMIO writes via regmap_update_bits() and
regmap_clear_bits().
Will accessing MMIO registers while the peripheral's clock is gated cause a
system bus hang (hard freeze or kernel panic) when a privileged user unloads
the driver module or unbinds the device via sysfs?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902201640.2024648-1-mukesh.ojha@oss.qualcomm.com?part=6
next prev parent reply other threads:[~2026-09-02 20:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 20:16 [PATCH v2 0/11] drm: Use devm_of_reserved_mem_device_init() Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 1/11] drm: logicvc: " Mukesh Ojha
2026-09-02 20:30 ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 2/11] drm: hdlcd: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 3/11] drm: pl111: " Mukesh Ojha
2026-09-02 20:33 ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 4/11] drm: komeda: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 5/11] drm: malidp: " Mukesh Ojha
2026-09-02 20:35 ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 6/11] drm: ingenic: " Mukesh Ojha
2026-09-02 20:27 ` sashiko-bot [this message]
2026-09-02 20:16 ` [PATCH v2 7/11] drm: kmb: " Mukesh Ojha
2026-09-02 20:31 ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 8/11] drm: sun4i: " Mukesh Ojha
2026-09-02 20:16 ` [PATCH v2 9/11] drm: xlnx: zynqmp_dpsub: " Mukesh Ojha
2026-09-02 20:31 ` sashiko-bot
2026-09-02 20:55 ` Laurent Pinchart
2026-09-02 20:16 ` [PATCH v2 10/11] drm: aspeed: " Mukesh Ojha
2026-09-02 20:35 ` sashiko-bot
2026-09-02 20:16 ` [PATCH v2 11/11] drm: arcpgu: " Mukesh Ojha
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=20260902202727.B4CE71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mukesh.ojha@oss.qualcomm.com \
--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