From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201249; b=WaDC5t50yaR2+rkWgfFkitqYPA+UzFoZweCZ0E606aY0fEvXQvuKBN1NzAt8Gyl5No7y eDb54TpAT1Nwh9j7BQLT6KkoBevgp4y1u5Wx88+CKpIMl2WLBtzFgEjmQiKPRcDMKGWS4 rDuOFoKVSny5PbekdEK9zoTihdoSkRyB9oGqonxQ4LFrLmUfHC7HNeq8cUQuK5T1kPuy3 Oo2HsS2+UAorXZZ3pvLh7OM5GeAeLLMFRzvA439SGOQyAdt0fWCPuUeUSiKWKIPFE2dXo mB53ulVHdNqeJER74dWzDQHh1C0TSf7hh2nP6qnh9JbFaBHyd/IdEyk3c6s5CzqoEDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201249; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Txh1X6pRnrZP624R5PEJC6xbIOlbabP/kQfqMOdXO4o=; b=1rAvkduF+0wuCFTNEpaQ6B+ubq6lQfIwi+BQSbM71IfqXXUKz7n+FobJ0laKu2uOMx2w Q3hTiTznhulJSsS8mOIgqqLmpVn8JbCpfp4gWMc1sxP3/oFlewW6GE7u6gFBrdlOGFH1A RzB/FZ2w2GG3p+uy4+fU66QhpIpTi6JJXJzy/5geDM6MJznFj7TfM9wp2Skf717SfT6Yz hKzRaKNHpcpxocuDfooLlOuxzIT3NGHpnUB+Siglo7LOuMjoEnckSx4GdPpCe0In9dwmI 9GJZi92Pe6rA21swyQZgdhKhO80cI0f1fUAiao0uomC6bJSr5zuu5Xg63kvE+ufsi+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G1vKwpxm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D2A1606A681 for ; Wed, 2 Dec 2026 08:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G1vKwpxm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 729711F00923; Wed, 2 Dec 2026 08:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796201248; bh=Txh1X6pRnrZP624R5PEJC6xbIOlbabP/kQfqMOdXO4o=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=G1vKwpxm+JwL6aPb7EjXpxsbiYCWP6qR2BY6I3/SSQJh/VztkQ7eF8byIz9oF7HJI DPWOht5B5gq+9K6LohIoSiOya0sQB0P+TMq8XJihxF2uZNyyuQEixvCQ6SNX2wJLx8 DEChlCuUVbRGEefhjUt72zZ/5xvfZMBOPHZ2Ad/9fPETuMRHItiD89+RAkIx5RZJsU PLReRAxyaIX70sFbUq2gBOAhH44xSnbMEbuiepzbUW0G6fyLL1zfJvDsCOVBBeIqkG uTFPyS2nMlRJ800x7uL15lwIjKNUOhlQV2B5rId+a/OdRn/hPvrtfozKK0usbxHOvz QT8ec9owiqBaA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RESEND PATCH] sparc64: Fix leaked platform_device reference in schizo_register_error_handlers() Reply-To: sashiko-reviews@lists.linux.dev To: "Ma Ke" Cc: sparclinux@vger.kernel.org In-Reply-To: <20261202083827.1817564-1-make_ruc2021@163.com> References: <20261202083827.1817564-1-make_ruc2021@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 08:47:28 +0000 X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 > sparc64: Fix leaked platform_device reference in schizo_register_error_ha= ndlers() > > 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 po= inter in pci_pbm_info.") > Cc: stable@vger.kernel.org > Signed-off-by: Ma Ke [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_schiz= o.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 p= ci_pbm_info *pbm) > =20 > upa_writeq((SCHIZO_SAFERRCTRL_EN | err_mask), > pbm->controller_regs + SCHIZO_SAFARI_ERRCTRL); > + > + platform_device_put(op); > } > =20 > 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 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202083827.1817= 564-1-make_ruc2021@163.com?part=3D1