Skip to content

Commit 42379b9

Browse files
committed
Merge branch 'dpaa2-eth-small-cleanup'
Ioana Ciornei says: ==================== dpaa2-eth: small cleanup These 3 patches are just part of a small cleanup on the dpaa2-eth and the dpaa2-switch drivers. In case we are hitting a case in which the fwnode of the root dprc device we initiate a deferred probe. On the dpaa2-switch side, if we are on the remove path, make sure that we check for a non-NULL pointer before accessing the port private structure. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 257367c + d1a9b84 commit 42379b9

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
4141
static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
4242
u16 dpmac_id)
4343
{
44-
struct fwnode_handle *fwnode, *parent, *child = NULL;
44+
struct fwnode_handle *fwnode, *parent = NULL, *child = NULL;
4545
struct device_node *dpmacs = NULL;
4646
int err;
4747
u32 id;
@@ -54,8 +54,17 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
5454
parent = of_fwnode_handle(dpmacs);
5555
} else if (is_acpi_node(fwnode)) {
5656
parent = fwnode;
57+
} else {
58+
/* The root dprc device didn't yet get to finalize it's probe,
59+
* thus the fwnode field is not yet set. Defer probe if we are
60+
* facing this situation.
61+
*/
62+
return ERR_PTR(-EPROBE_DEFER);
5763
}
5864

65+
if (!parent)
66+
return NULL;
67+
5968
fwnode_for_each_child_node(parent, child) {
6069
err = -EINVAL;
6170
if (is_acpi_device_node(child))
@@ -327,6 +336,7 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
327336
{
328337
struct fsl_mc_device *dpmac_dev = mac->mc_dev;
329338
struct net_device *net_dev = mac->net_dev;
339+
struct fwnode_handle *fw_node;
330340
int err;
331341

332342
err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id,
@@ -346,7 +356,13 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
346356
/* Find the device node representing the MAC device and link the device
347357
* behind the associated netdev to it.
348358
*/
349-
mac->fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
359+
fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
360+
if (IS_ERR(fw_node)) {
361+
err = PTR_ERR(fw_node);
362+
goto err_close_dpmac;
363+
}
364+
365+
mac->fw_node = fw_node;
350366
net_dev->dev.of_node = to_of_node(mac->fw_node);
351367

352368
return 0;

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ static int dpaa2_switch_dellink(struct ethsw_core *ethsw, u16 vid)
394394

395395
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
396396
ppriv_local = ethsw->ports[i];
397-
ppriv_local->vlans[vid] = 0;
397+
if (ppriv_local)
398+
ppriv_local->vlans[vid] = 0;
398399
}
399400

400401
return 0;
@@ -1896,9 +1897,11 @@ static int dpaa2_switch_port_del_vlan(struct ethsw_port_priv *port_priv, u16 vid
18961897
/* Delete VLAN from switch if it is no longer configured on
18971898
* any port
18981899
*/
1899-
for (i = 0; i < ethsw->sw_attr.num_ifs; i++)
1900-
if (ethsw->ports[i]->vlans[vid] & ETHSW_VLAN_MEMBER)
1900+
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
1901+
if (ethsw->ports[i] &&
1902+
ethsw->ports[i]->vlans[vid] & ETHSW_VLAN_MEMBER)
19011903
return 0; /* Found a port member in VID */
1904+
}
19021905

19031906
ethsw->vlans[vid] &= ~ETHSW_VLAN_GLOBAL;
19041907

0 commit comments

Comments
 (0)