Skip to content

Commit d5a619b

Browse files
vivienJakub Kicinski
authored andcommitted
net: dsa: sja1105: register switch before assigning port private data
Like the dsa_switch_tree structures, the dsa_port structures will be allocated on switch registration. The SJA1105 driver is the only one accessing the dsa_port structure after the switch allocation and before the switch registration. For that reason, move switch registration prior to assigning the priv member of the dsa_port structures. Signed-off-by: Vivien Didelot <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ef2025e commit d5a619b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,15 @@ static int sja1105_probe(struct spi_device *spi)
20572057

20582058
tagger_data = &priv->tagger_data;
20592059

2060+
mutex_init(&priv->ptp_data.lock);
2061+
mutex_init(&priv->mgmt_lock);
2062+
2063+
sja1105_tas_setup(ds);
2064+
2065+
rc = dsa_register_switch(priv->ds);
2066+
if (rc)
2067+
return rc;
2068+
20602069
/* Connections between dsa_port and sja1105_port */
20612070
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
20622071
struct sja1105_port *sp = &priv->ports[i];
@@ -2065,12 +2074,8 @@ static int sja1105_probe(struct spi_device *spi)
20652074
sp->dp = dsa_to_port(ds, i);
20662075
sp->data = tagger_data;
20672076
}
2068-
mutex_init(&priv->ptp_data.lock);
2069-
mutex_init(&priv->mgmt_lock);
20702077

2071-
sja1105_tas_setup(ds);
2072-
2073-
return dsa_register_switch(priv->ds);
2078+
return 0;
20742079
}
20752080

20762081
static int sja1105_remove(struct spi_device *spi)

0 commit comments

Comments
 (0)