Skip to content

Commit a7fdaf0

Browse files
Erni Sri Satya VennelaPaolo Abeni
authored andcommitted
net: mana: Don't overwrite port probe error with add_adev result
In mana_probe(), if mana_probe_port() fails for any port, the error is stored in 'err' and the loop breaks. However, the subsequent unconditional 'err = add_adev(gd, "eth")' overwrites this error. If add_adev() succeeds, mana_probe() returns success despite ports being left in a partially initialized state (ac->ports[i] == NULL). Only call add_adev() when there is no prior error, so the probe correctly fails and triggers mana_remove() cleanup. Fixes: a69839d ("net: mana: Add support for auxiliary device") Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com> Link: https://patch.msgid.link/20260420124741.1056179-5-ernis@linux.microsoft.com Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 50271d7 commit a7fdaf0

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

drivers/net/ethernet/microsoft/mana/mana_en.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,10 +3680,9 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
36803680
if (!resuming) {
36813681
for (i = 0; i < ac->num_ports; i++) {
36823682
err = mana_probe_port(ac, i, &ac->ports[i]);
3683-
/* we log the port for which the probe failed and stop
3684-
* probes for subsequent ports.
3685-
* Note that we keep running ports, for which the probes
3686-
* were successful, unless add_adev fails too
3683+
/* Log the port for which the probe failed, stop probing
3684+
* subsequent ports, and skip add_adev.
3685+
* mana_remove() will clean up already-probed ports.
36873686
*/
36883687
if (err) {
36893688
dev_err(dev, "Probe Failed for port %d\n", i);
@@ -3697,10 +3696,9 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
36973696
enable_work(&apc->queue_reset_work);
36983697
err = mana_attach(ac->ports[i]);
36993698
rtnl_unlock();
3700-
/* we log the port for which the attach failed and stop
3701-
* attach for subsequent ports
3702-
* Note that we keep running ports, for which the attach
3703-
* were successful, unless add_adev fails too
3699+
/* Log the port for which the attach failed, stop
3700+
* attaching subsequent ports, and skip add_adev.
3701+
* mana_remove() will clean up already-attached ports.
37043702
*/
37053703
if (err) {
37063704
dev_err(dev, "Attach Failed for port %d\n", i);
@@ -3709,7 +3707,8 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
37093707
}
37103708
}
37113709

3712-
err = add_adev(gd, "eth");
3710+
if (!err)
3711+
err = add_adev(gd, "eth");
37133712

37143713
schedule_delayed_work(&ac->gf_stats_work, MANA_GF_STATS_PERIOD);
37153714

0 commit comments

Comments
 (0)