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=1796201624; b=myybkuO6ilrN7UcS53A0qZK+u4OwKSH7jw/nXOfdmO7ap5DMLvI9+HS60vZyI3DkE5Km LG0OTJlPLrOWK98gsxr/X/qWmwYMviRwI79vGzghX1bOdH9cf7Cf8FrA6bLWti0D2yyG2 fMAUkdUXZxwv2eEWb7ruhfjVLzmcJziW+mPOKc3c48JJwgqAKaF8ifT8aEtyCxtheR4I7 lnqGjeh7FRHikWazVDi6ahGGOgeimT1KxokiK0936kecqA58me9gnE5BpwjhYWwfizfSz zn+ZjQ/1zHEqbWQMSnc+b7w11/zJx/jJI9LqJ2T5RgdM2FoqT4YDQ1W6MfxY6N9y7Cw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201624; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=mDdYuzAMwfFWLHJSTBEfVEv6Y6x8IES7n6QWcyWMfIw=; b=cPlsD4JLxOAS9k9PnpRCrJDXY5Fi6WM1gUXBHU3ZUAFbBTY1AFmkXqekfsKL6n7Bw4Vc KXY/5Fo8R5UujnAX1X0Mc3ExALThR30vbw0/cT0Rery/VrBHTS8tb1Y6HT+82GJn5yUxy DKB2uK+U7aLmxhy720MhscTd8pP4hkIjkcNVdk+9G3Ri47L0SZpWc0LiUeuVTNOy1nuUu GpAUl+uT9AiouCkUEQXb3U+T68WU0rpR1RiQl9ptxfhX50hWMjbj5rQVs/523/vW+WOP0 HB7gy1jvQ4dwMGG4zJAKO+WXJh8NY1Gfn/IOTXQod5xOpxG0y4EraPXzB8WAlz9Qg2w== 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=BQb2JTi1; 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 D7529606A68C for ; Wed, 2 Dec 2026 08:53:44 +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=BQb2JTi1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 834851F000C1; Wed, 2 Dec 2026 08:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796201624; bh=mDdYuzAMwfFWLHJSTBEfVEv6Y6x8IES7n6QWcyWMfIw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BQb2JTi1inTtAsYq/umLBUauO60iK6Jvl7abBIWsiz9qCeLXjGcVd4YdROMhhR15y MjO5ESz/0vya3NUWRt1JSMvbc/sG8MmTWf4gYgSrlhR7/x6hSkuIqzgVMGvjHG9fkV hnb57Afkzqiz88gc+8nl1JBFtC/UHcGHO6aECjNxkSBsis4j02AtlwH4+oY3typelW E5KKANEs05pTGow4JCW4lUg807FKbf49u0Lllmgt8bT1yZ5fDry6t64ZjIAAik4Q3R GMULHpcLMInft4vBp5LbjNRM9zTeXWDQ30cdDR6/jPOfUAb2GiTwdV14P7oGK6V0At Joqwohc1vKA6g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RESEND PATCH v2] sparc: Fix leaked platform_device references from of_find_device_by_node() Reply-To: sashiko-reviews@lists.linux.dev To: "Ma Ke" Cc: sparclinux@vger.kernel.org In-Reply-To: <20261202084556.1829535-1-make_ruc2021@163.com> References: <20261202084556.1829535-1-make_ruc2021@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 08:53:44 +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 1 potential issue to consider: - [Medium] sparc: platform_device ref leak on out-of-bounds index in OF helpers -- commit 0bdd0e6adc60c51f4dd86a3e1f30c5aaeddff7ad Author: Ma Ke sparc: Fix leaked platform_device references from of_find_device_by_node() This commit adds platform_device_put() calls to irq_of_parse_and_map(), of_address_to_resource(), of_iomap(), and of_propagate_archdata() to drop the reference acquired by of_find_device_by_node(). > diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_= device_common.c > index e717a56efc5d3..818bff54c2ecc 100644 > --- a/arch/sparc/kernel/of_device_common.c > +++ b/arch/sparc/kernel/of_device_common.c > @@ -16,11 +16,15 @@ > unsigned int irq_of_parse_and_map(struct device_node *node, int index) > { > struct platform_device *op =3D of_find_device_by_node(node); > + unsigned int irq; > =20 > if (!op || index >=3D op->archdata.num_irqs) > return 0; > =20 > - return op->archdata.irqs[index]; > + irq =3D op->archdata.irqs[index]; > + platform_device_put(op); > + > + return irq; > } > EXPORT_SYMBOL(irq_of_parse_and_map); > =20 > @@ -33,6 +37,8 @@ int of_address_to_resource(struct device_node *node, in= t index, > return -EINVAL; > =20 > memcpy(r, &op->archdata.resource[index], sizeof(*r)); > + platform_device_put(op); > + > return 0; > } > EXPORT_SYMBOL_GPL(of_address_to_resource); > @@ -41,13 +47,16 @@ void __iomem *of_iomap(struct device_node *node, int = index) > { > struct platform_device *op =3D of_find_device_by_node(node); > struct resource *r; > + void __iomem *ret; > =20 > if (!op || index >=3D op->num_resources) > return NULL; > =20 > r =3D &op->archdata.resource[index]; > + ret =3D of_ioremap(r, 0, resource_size(r), (char *) r->name); > + platform_device_put(op); > =20 > - return of_ioremap(r, 0, resource_size(r), (char *) r->name); > + return ret; > } [Severity: Medium] Do irq_of_parse_and_map(), of_address_to_resource(), and of_iomap() still leak op when op is non-NULL and index is out of bounds? Callers such as of_device_alloc() probe resources by incrementing index until of_address_to_resource() returns -EINVAL, hitting the early return with a valid op on every call. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202084556.1829= 535-1-make_ruc2021@163.com?part=3D1