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 571893BADB1 for ; Wed, 10 Jun 2026 12:39:02 +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=1781095144; cv=none; b=Q//yjtdAR1Oj4F2tc8cn2NTDAKaI605q5Pxr/SlyzmIpwHT7fgI0EwnQte8ht3RTF330z/Pv4VHcabkzUqEdPI/XCStfMl2brJefr2P3WoSH+u9WtDDI4fCXtLQyLkHcmtK/pjxVcsjrJ0xCGFvmPPY4z4CcoI8hOfhFVaslY8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781095144; c=relaxed/simple; bh=HrSqzNTnR4WRNRS8bUmISNB9c7Wek/Bkm+ZmnpD9ACI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KpPc6L4oQnyJYJigATPXOQ6tzBWFZO/ZD11Pqea+X833o2cyneqw/65NRAmSXrP84iQlHqabGuGJU6CjM+u1yVgPDp78KO4dFtUjp89KCB3Yuq+R+KfbiYH1n8fOHc/WhqpWNq1P31WcurUbS726gjhNhKqxw1rVEvBT1uk2mvQ= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=b7zl1Hid; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="b7zl1Hid" 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 7F32E25E3 for ; Wed, 10 Jun 2026 05:38:56 -0700 (PDT) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F3A273FDE2 for ; Wed, 10 Jun 2026 05:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781095141; bh=HrSqzNTnR4WRNRS8bUmISNB9c7Wek/Bkm+ZmnpD9ACI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b7zl1Hidc2uect38CzDswblOd2JI/wXKElWwuxtrUgjWWCwsVDqCMkLTUv5YQv3Ii YPeDVwnT1r7Ms6WNgWP1FCai+hjlwguCENk/wDgqSJudGGzghi/470LwBpZr7N6QT3 ucj+UEeqoKcgZQMUfH4Sid4EDyaLHZVx3B2Qnj5o= Date: Wed, 10 Jun 2026 13:38:55 +0100 From: Liviu Dudau To: Weigang He Cc: Sudeep Holla , Lorenzo Pieralisi , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bus: vexpress-config: fix device_node refcount leak in vexpress_syscfg_probe() Message-ID: References: <20260610033054.2117363-1-geoffreyhe2@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260610033054.2117363-1-geoffreyhe2@gmail.com> On Wed, Jun 10, 2026 at 01:30:54PM +1000, Weigang He wrote: > vexpress_syscfg_probe() iterates the "arm,vexpress,config-bus" > compatible nodes and, for each one, takes a reference to the bridge > phandle via of_parse_phandle(): > > bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0); > > bridge_np is only compared against pdev->dev.parent->of_node and is > never released - neither on the "continue" path when it does not match, > nor on the path that calls of_platform_populate() and falls through to > the next loop iteration. Each matching iteration leaks one device_node > reference; the leak repeats on every probe (driver bind/unbind, module > reload, or EPROBE_DEFER retry). > > This is a regression of commit 557e37c05f28 ("bus: vexpress-config: add > missing of_node_put after calling of_parse_phandle"), which fixed the > equivalent leak in the predecessor function vexpress_config_populate(). > Commit a5a38765ac79 ("bus: vexpress-config: simplify config bus > probing") removed that function and inlined the loop into the probe > routine, but did not carry over the of_node_put(). > > Use the __free(device_node) cleanup attribute on bridge_np so the > reference is released automatically at the end of each loop iteration. > > Found by static analysis tool CodeQL. > > Fixes: a5a38765ac79 ("bus: vexpress-config: simplify config bus probing") > Signed-off-by: Weigang He Reviewed-by: Liviu Dudau Thanks for the fix! Best regards, Liviu > --- > drivers/bus/vexpress-config.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c > index 64ee920721ee7..cc247483d3823 100644 > --- a/drivers/bus/vexpress-config.c > +++ b/drivers/bus/vexpress-config.c > @@ -390,9 +390,9 @@ static int vexpress_syscfg_probe(struct platform_device *pdev) > } > > for_each_compatible_node(node, NULL, "arm,vexpress,config-bus") { > - struct device_node *bridge_np; > + struct device_node *bridge_np __free(device_node) = > + of_parse_phandle(node, "arm,vexpress,config-bridge", 0); > > - bridge_np = of_parse_phandle(node, "arm,vexpress,config-bridge", 0); > if (bridge_np != pdev->dev.parent->of_node) > continue; > > > base-commit: 0f61b1860cc3f52aef9036d7235ed1f017632193 > -- > 2.43.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯