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] [day] [month] [year] [list]
Message-ID: <b1f33b6e-1054-476d-8cd4-6a0d1e02d31b@lunn.ch>
Date: Tue, 10 Sep 2024 16:44:56 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: yoshihiro.shimoda.uh@...esas.com, davem@...emloft.net,
	edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
	horms@...nel.org, wojciech.drewek@...el.com,
	niklas.soderlund+renesas@...natech.se, netdev@...r.kernel.org,
	linux-renesas-soc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: rswitch: Fix a possible memory leak in
 rswitch_phy_device_init()

On Mon, Sep 09, 2024 at 05:28:25PM +0800, Jinjie Ruan wrote:
> of_phy_find_device() calls bus_find_device(), which calls get_device()
> on the returned struct device * to increment the refcount. The current
> implementation does not decrement the refcount, which causes memory leak.
> 
> So add the missing phy_device_free() call to decrement the
> refcount via put_device() to balance the refcount.
> 
> Fixes: 0df024d0f1d3 ("net: renesas: rswitch: Add host_interfaces setting")
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
> ---
>  drivers/net/ethernet/renesas/rswitch.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index ff50e20856ec..69a67bd75f33 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1404,6 +1404,7 @@ static int rswitch_phy_device_init(struct rswitch_device *rdev)
>  		goto out;
>  	__set_bit(rdev->etha->phy_interface, phydev->host_interfaces);
>  	phydev->mac_managed_pm = true;
> +	phy_device_free(phydev);
>  
>  	phydev = of_phy_connect(rdev->ndev, phy, rswitch_adjust_link, 0,
>  				rdev->etha->phy_interface);

This has the same problem as discussed in

net: ethernet: nxp: Fix a possible memory leak in lpc_mii_probe()

I've not looked to see if there are more of these 'fixes'. If there
are, it would be good to self NACK them so they don't get accidentally
merged.

    Andrew

---
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ