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: <aec90f22-da8d-4d03-bde6-43fa2bee2e25@lunn.ch>
Date: Fri, 21 Nov 2025 14:40:58 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Ma Ke <make24@...as.ac.cn>
Cc: olteanv@...il.com, davem@...emloft.net, edumazet@...gle.com,
	kuba@...nel.org, pabeni@...hat.com, horms@...nel.org,
	florian.fainelli@...adcom.com, stephen@...workplumber.org,
	robh@...nel.org, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] net: dsa: Fix error handling in dsa_port_parse_of

On Fri, Nov 21, 2025 at 11:51:30AM +0800, Ma Ke wrote:
> When of_find_net_device_by_node() successfully acquires a reference to
> a network device but the subsequent call to dsa_port_parse_cpu()
> fails, dsa_port_parse_of() returns without releasing the reference
> count on the network device.
> 
> of_find_net_device_by_node() increments the reference count of the
> returned structure, which should be balanced with a corresponding
> put_device() when the reference is no longer needed.
> 
> Found by code review.
> 
> Cc: stable@...r.kernel.org
> Fixes: 6ca80638b90c ("net: dsa: Use conduit and user terms")

Why did you pick this commit for the Fixes tag?

> @@ -1259,7 +1260,13 @@ static int dsa_port_parse_of(struct dsa_port *dp, struct device_node *dn)
>  			return -EPROBE_DEFER;
>  
>  		user_protocol = of_get_property(dn, "dsa-tag-protocol", NULL);
> -		return dsa_port_parse_cpu(dp, conduit, user_protocol);
> +		err = dsa_port_parse_cpu(dp, conduit, user_protocol);
> +		if (err) {
> +			put_device(conduit);
> +			return err;
> +		}
> +
> +		return 0;
>  	}
>  
>  	if (link)
> -- 
> 2.17.1

You can simplify this to:

		err = dsa_port_parse_cpu(dp, conduit, user_protocol);
		if (err) 
			put_device(conduit);

		return err;

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

    Andrew

---
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ