From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vc4: Fix firmware reference leak in vc4_hvs_bind()
Date: Fri, 06 Nov 2026 09:28:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-201107@kernel.org> (raw)
In-Reply-To: <20261106092016.2282805-1-vulab@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/vc4: resource leak and NULL pointer dereference in
vc4_hvs_bind() [1]
--
commit 17330184776a3fb8ffab5b0b09aa15bba8f8bd33
Author: Wentao Liang <vulab@iscas.ac.cn>
drm/vc4: Fix firmware reference leak in vc4_hvs_bind()
This commit moves the rpi_firmware_find_node() and rpi_firmware_get()
calls in vc4_hvs_bind() below the devm_clk_get() lookups so the firmware
reference is not leaked when clock acquisition fails.
> diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
> index b1fb096858ccc..537aaa9921293 100644
> --- a/drivers/gpu/drm/vc4/vc4_hvs.c
> +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
> @@ -1677,15 +1677,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
> struct device_node *node;
> unsigned int max_rate;
>
> - node = rpi_firmware_find_node();
> - if (!node)
> - return -EINVAL;
> -
> - firmware = rpi_firmware_get(node);
> - of_node_put(node);
> - if (!firmware)
> - return -EPROBE_DEFER;
> -
> hvs->core_clk = devm_clk_get(&pdev->dev,
> (vc4->gen >= VC4_GEN_6_C) ? "core" : NULL);
> if (IS_ERR(hvs->core_clk)) {
> @@ -1700,6 +1691,15 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
> return PTR_ERR(hvs->disp_clk);
> }
>
> + node = rpi_firmware_find_node();
> + if (!node)
> + return -EINVAL;
> +
> + firmware = rpi_firmware_get(node);
> + of_node_put(node);
> + if (!firmware)
> + return -EPROBE_DEFER;
> +
> max_rate = rpi_firmware_clk_get_max_rate(firmware,
> RPI_FIRMWARE_CORE_CLK_ID);
> rpi_firmware_put(firmware);
[Severity: High]
This problem wasn't introduced by this patch, but can vc4_hvs_irq_handler()
dereference a NULL vc4->hvs pointer after component unbind [1]?
vc4_hvs_bind() allocates hvs and registers vc4_hvs_irq_handler() with
devm_kzalloc() and devm_request_irq() tied to the component platform
device rather than the aggregate DRM lifetime. When the component
unbinds (for example on aggregate probe deferral), vc4_hvs_unbind() sets
vc4->hvs to NULL while the devres-managed IRQ handler remains registered:
drivers/gpu/drm/vc4/vc4_hvs.c:vc4_hvs_irq_handler() {
...
struct vc4_dev *vc4 = to_vc4_dev(dev);
...
status = HVS_READ(SCALER_DISPSTAT);
...
}
If an interrupt fires after unbind, HVS_READ() dereferences
vc4->hvs->regs, causing a NULL pointer dereference, and a subsequent
re-bind leaks devres allocations and fails in devm_request_irq() with
-EBUSY.
[1] https://sashiko.dev/#/bug/linux-4ad12be9-d1a5-441d-9845-195d42c3f880
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106092016.2282805-1-vulab@iscas.ac.cn?part=1
next prev parent reply other threads:[~2026-11-06 9:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:41 [PATCH] drm/vc4: Fix firmware reference leak in vc4_hvs_bind() Wentao Liang
2026-09-17 21:03 ` Maíra Canal
2026-11-06 9:12 ` Wentao Liang
2026-11-06 9:20 ` Wentao Liang
2026-11-06 9:28 ` sashiko-bot [this message]
2026-11-09 12:38 ` Maíra Canal
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=sashiko-outbox-201107@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vulab@iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.