Patch "net: netsec: fix error handling in netsec_register_mdio()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: netsec: fix error handling in netsec_register_mdio()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-netsec-fix-error-handling-in-netsec_register_mdi.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit cd6f73f5765009459d8394589942a7f3a7fa02a0
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Wed Oct 19 14:41:04 2022 +0800

    net: netsec: fix error handling in netsec_register_mdio()
    
    [ Upstream commit 94423589689124e8cd145b38a1034be7f25835b2 ]
    
    If phy_device_register() fails, phy_device_free() need be called to
    put refcount, so memory of phy device and device name can be freed
    in callback function.
    
    If get_phy_device() fails, mdiobus_unregister() need be called,
    or it will cause warning in mdiobus_free() and kobject is leaked.
    
    Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221019064104.3228892-1-yangyingliang@xxxxxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 1f46af136aa8..f0451911ab8f 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -1964,11 +1964,13 @@ static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr)
 			ret = PTR_ERR(priv->phydev);
 			dev_err(priv->dev, "get_phy_device err(%d)\n", ret);
 			priv->phydev = NULL;
+			mdiobus_unregister(bus);
 			return -ENODEV;
 		}
 
 		ret = phy_device_register(priv->phydev);
 		if (ret) {
+			phy_device_free(priv->phydev);
 			mdiobus_unregister(bus);
 			dev_err(priv->dev,
 				"phy_device_register err(%d)\n", ret);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux