From: sashiko-bot@kernel.org
To: "Ma Ke" <make_ruc2021@163.com>
Cc: sparclinux@vger.kernel.org
Subject: Re: [RESEND PATCH] sparc64: Fix leaked platform_device reference in schizo_register_error_handlers()
Date: Wed, 02 Dec 2026 08:47:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-245225@kernel.org> (raw)
In-Reply-To: <20261202083827.1817564-1-make_ruc2021@163.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] sparc64: unfixed platform_device leak in
tomatillo_register_error_handlers()
- [Low] sparc64: redundant of_find_device_by_node() in
schizo_register_error_handlers()
- [Low] sparc64: inaccurate Fixes tag in
schizo_register_error_handlers() leak fix
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] sparc: null pointer dereferences after of_find_device_by_node()
[1]
--
commit 107e100efab4d240d72ab8b5634d12dbba9daf53
Author: Ma Ke <make_ruc2021@163.com>
> sparc64: Fix leaked platform_device reference in schizo_register_error_handlers()
>
> of_find_device_by_node() is documented in drivers/of/platform.c:
>
> * Takes a reference to the embedded struct device which needs to be
> * dropped after use.
>
> schizo_register_error_handlers() looks up the platform device backing
> the PBM and never drops that reference.
> tomatillo_register_error_handlers() in the same file has the leak.
>
> Release the reference once the error interrupts have been registered.
>
> Found by code review.
>
> Fixes: 22fecbae4446 ("sparc64: Record OF device instead of device node pointer in pci_pbm_info.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
[Severity: Low]
Does the Fixes tag point to the commit that introduced the leak? Commit
22fecbae4446 ("sparc64: Record OF device instead of device node pointer in
pci_pbm_info.") only changed the argument of of_find_device_by_node() from
pbm->prom_node to pbm->op->node, whereas the unreleased
of_find_device_by_node() calls were introduced in 2b1e59787198
("[SPARC64]: of_device layer IRQ resolution") and consolidated at function
entry in 34768bc83291 ("[SPARC64] PCI: Use root list of pbm's instead of
pci_controller_info's").
> diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c
> index 421aba00e6b0a..aa0ed8f1eac6c 100644
> --- a/arch/sparc/kernel/pci_schizo.c
> +++ b/arch/sparc/kernel/pci_schizo.c
> @@ -1047,6 +1047,8 @@ static void schizo_register_error_handlers(struct pci_pbm_info *pbm)
>
> upa_writeq((SCHIZO_SAFERRCTRL_EN | err_mask),
> pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL);
> +
> + platform_device_put(op);
> }
>
> static void pbm_config_busmastering(struct pci_pbm_info *pbm)
[Severity: Medium]
Should tomatillo_register_error_handlers() also be fixed here? The commit
message notes that tomatillo_register_error_handlers() has the same
of_find_device_by_node(pbm->op->dev.of_node) reference leak, and
schizo_scan_bus() calls tomatillo_register_error_handlers() instead of
schizo_register_error_handlers() when pbm->chip_type is
PBM_CHIP_TYPE_TOMATILLO.
[Severity: Low]
Is of_find_device_by_node(pbm->op->dev.of_node) needed at all in
schizo_register_error_handlers() and tomatillo_register_error_handlers()?
schizo_pbm_init() already sets pbm->op to the PBM's struct platform_device
before calling schizo_scan_bus(), so both functions could use pbm->op
directly instead of looking it up via pbm->op->dev.of_node and dropping the
extra reference.
[Severity: High]
This problem wasn't introduced by this patch, but can
of_find_device_by_node() return NULL and cause a NULL pointer dereference in
schizo_register_error_handlers() and of_propagate_archdata() [1]? If
a device tree node has no registered platform device, both functions
immediately dereference op (via op->archdata.irqs[] or
op->dev.archdata.iommu) without checking for NULL, panicking the kernel
during boot.
[1] https://sashiko.dev/#/bug/linux-a3f0b479-43e6-4cf9-a532-2a1e33c98936
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202083827.1817564-1-make_ruc2021@163.com?part=1
prev parent reply other threads:[~2026-12-02 8:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 8:38 [RESEND PATCH] sparc64: Fix leaked platform_device reference in schizo_register_error_handlers() Ma Ke
2026-12-02 8:47 ` 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=sashiko-outbox-245225@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=make_ruc2021@163.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sparclinux@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 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.