Skip to content

Commit d1cc0e9

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: error checking when calling ocelot_init()
ocelot_init() allocates memory, resets the switch and polls for a status register, things which can fail. Stop probing the driver in that case, and propagate the error result. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c9d4b2c commit d1cc0e9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

drivers/net/dsa/ocelot/felix.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ static int felix_setup(struct dsa_switch *ds)
585585
if (err)
586586
return err;
587587

588-
ocelot_init(ocelot);
588+
err = ocelot_init(ocelot);
589+
if (err)
590+
return err;
591+
589592
if (ocelot->ptp) {
590593
err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
591594
if (err) {

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,10 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
10021002
ocelot->vcap_is2_actions = vsc7514_vcap_is2_actions;
10031003
ocelot->vcap = vsc7514_vcap_props;
10041004

1005-
ocelot_init(ocelot);
1005+
err = ocelot_init(ocelot);
1006+
if (err)
1007+
goto out_put_ports;
1008+
10061009
if (ocelot->ptp) {
10071010
err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info);
10081011
if (err) {

0 commit comments

Comments
 (0)