]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: mv643xx_eth: process retval from of_get_mac_address
authorMauri Sandberg <maukka@ext.kapsi.fi>
Wed, 23 Feb 2022 14:23:37 +0000 (16:23 +0200)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 7 Mar 2022 10:45:58 +0000 (11:45 +0100)
BugLink: https://bugs.launchpad.net/bugs/1963891
commit 42404d8f1c01861b22ccfa1d70f950242720ae57 upstream.

Obtaining a MAC address may be deferred in cases when the MAC is stored
in an NVMEM block, for example, and it may not be ready upon the first
retrieval attempt and return EPROBE_DEFER.

It is also possible that a port that does not rely on NVMEM has been
already created when getting the defer request. Thus, also the resources
allocated previously must be freed when doing a roll-back.

Fixes: 76723bca2802 ("net: mv643xx_eth: add DT parsing support")
Signed-off-by: Mauri Sandberg <maukka@ext.kapsi.fi>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20220223142337.41757-1-maukka@ext.kapsi.fi
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/ethernet/marvell/mv643xx_eth.c

index 28d5ad296646aef44c4cb15f8aa3aebe37270bc2..1b61fe2e9b4d5ea93c99d49cb9978f93678fa84e 100644 (file)
@@ -2700,6 +2700,16 @@ MODULE_DEVICE_TABLE(of, mv643xx_eth_shared_ids);
 
 static struct platform_device *port_platdev[3];
 
+static void mv643xx_eth_shared_of_remove(void)
+{
+       int n;
+
+       for (n = 0; n < 3; n++) {
+               platform_device_del(port_platdev[n]);
+               port_platdev[n] = NULL;
+       }
+}
+
 static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
                                          struct device_node *pnp)
 {
@@ -2736,7 +2746,9 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
                return -EINVAL;
        }
 
-       of_get_mac_address(pnp, ppd.mac_addr);
+       ret = of_get_mac_address(pnp, ppd.mac_addr);
+       if (ret)
+               return ret;
 
        mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size);
        mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr);
@@ -2800,21 +2812,13 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
                ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
                if (ret) {
                        of_node_put(pnp);
+                       mv643xx_eth_shared_of_remove();
                        return ret;
                }
        }
        return 0;
 }
 
-static void mv643xx_eth_shared_of_remove(void)
-{
-       int n;
-
-       for (n = 0; n < 3; n++) {
-               platform_device_del(port_platdev[n]);
-               port_platdev[n] = NULL;
-       }
-}
 #else
 static inline int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
 {