lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241012132137.GF77519@kernel.org>
Date: Sat, 12 Oct 2024 14:21:37 +0100
From: Simon Horman <horms@...nel.org>
To: Rosen Penev <rosenp@...il.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Andrew Lunn <andrew@...n.ch>,
	Shannon Nelson <shannon.nelson@....com>,
	Uwe Kleine-König <u.kleine-koenig@...libre.com>,
	Breno Leitao <leitao@...ian.org>,
	Jeff Johnson <quic_jjohnson@...cinc.com>,
	Christian Marangi <ansuelsmth@...il.com>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCHv6 net-next 7/7] net: ibm: emac: use of_find_matching_node

On Fri, Oct 11, 2024 at 12:56:22PM -0700, Rosen Penev wrote:
> Cleaner than using of_find_all_nodes and then of_match_node.
> 
> Also modified EMAC_BOOT_LIST_SIZE check to run before of_node_get to
> avoid having to call of_node_put on failure.
> 
> Signed-off-by: Rosen Penev <rosenp@...il.com>
> ---
>  drivers/net/ethernet/ibm/emac/core.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
> index faa483790b29..5265616400c2 100644
> --- a/drivers/net/ethernet/ibm/emac/core.c
> +++ b/drivers/net/ethernet/ibm/emac/core.c
> @@ -3253,21 +3253,17 @@ static void __init emac_make_bootlist(void)
>  	int cell_indices[EMAC_BOOT_LIST_SIZE];
>  
>  	/* Collect EMACs */
> -	while((np = of_find_all_nodes(np)) != NULL) {
> +	while((np = of_find_matching_node(np, emac_match))) {
>  		u32 idx;
>  
> -		if (of_match_node(emac_match, np) == NULL)
> -			continue;
>  		if (of_property_read_bool(np, "unused"))
>  			continue;
>  		if (of_property_read_u32(np, "cell-index", &idx))
>  			continue;
>  		cell_indices[i] = idx;
> -		emac_boot_list[i++] = of_node_get(np);
> -		if (i >= EMAC_BOOT_LIST_SIZE) {
> -			of_node_put(np);
> +		if (i >= EMAC_BOOT_LIST_SIZE)
>  			break;
> -		}
> +		emac_boot_list[i++] = of_node_get(np);

Reading the Kernel doc for of_find_matching_node() it seems
that of_node_put() needs to called each time it (and thus
of_find_matching_node() returns a np. But that doesn't seem
to be the case here. Am I mistaken?


>  	}
>  	max = i;
>  
> -- 
> 2.47.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ