From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD04253351 for ; Wed, 19 Mar 2025 11:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742383388; cv=none; b=UDo/C4k/v/uACFDQW9UuT3Gc9Myw3ahaEMj4rqSaQrq8VHPyJaxMUlpCcmpL4xuRb6yZfKWEKtJC+TLFJ8nXxCy7QPi5BnqA3zXrxakE0ns0FNHpbAoZlO8L6XGY89Gxnkhjm+mf3cYoXSKx8KmMUV/C6RE/cwOUuJk9/R+vEuE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742383388; c=relaxed/simple; bh=I2jlfu32GpD3lTkpDQ4wiTr/uiD2t4PxQ2WOakJAtsg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nkm086QYAq9N2izkoETyYxSegGDH8gm7Pwv90n8Vl2+0y3aA5EClnv+hvAX7y1c/juolKZrCcTFK9A+lzMJtXPwE2ki59IHYpisbMPyvw4erSQK+ZM5VoNo7yoS1UBwDxOMEQjzJ7XTGAA8PsCS9op0AmlQUTK2lPZLJSvQ0KH0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB306113E; Wed, 19 Mar 2025 04:23:14 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D1AD3F673; Wed, 19 Mar 2025 04:23:05 -0700 (PDT) Date: Wed, 19 Mar 2025 11:23:02 +0000 From: Mark Rutland To: Miaoqian Lin Cc: Lorenzo Pieralisi , Will Deacon , Hanjun Guo , Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firmware: psci: Fix refcount leak in psci_dt_init Message-ID: References: <20250318151712.28763-1-linmq006@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250318151712.28763-1-linmq006@gmail.com> On Tue, Mar 18, 2025 at 11:17:12PM +0800, Miaoqian Lin wrote: > Fix a reference counter leak in psci_dt_init() where of_node_put(np) was > missing after of_find_matching_node_and_match() when np is unavailable. > > Fixes: bff60792f994 ("arm64: psci: factor invocation code to drivers") > Signed-off-by: Miaoqian Lin The fixes tag is wrong. As of commit bff60792f994 the code was: | np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); | | if (!np) | return -ENODEV; ... which was correct. The bug was introduced later in commit: d09a0011ec0d511b ("drivers: psci: Allow PSCI node to be disabled") ... which added the of_device_is_available() check. Other than that, this looks fine. With the fixes tag corrected: Acked-by: Mark Rutland Mark. > --- > drivers/firmware/psci/psci.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c > index a1ebbe9b73b1..38ca190d4a22 100644 > --- a/drivers/firmware/psci/psci.c > +++ b/drivers/firmware/psci/psci.c > @@ -804,8 +804,10 @@ int __init psci_dt_init(void) > > np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); > > - if (!np || !of_device_is_available(np)) > + if (!np || !of_device_is_available(np)) { > + of_node_put(np); > return -ENODEV; > + } > > init_fn = (psci_initcall_t)matched_np->data; > ret = init_fn(np); > -- > 2.39.5 (Apple Git-154) >