Skip to content

Commit 1b45443

Browse files
Jijie Shaokuba-moo
authored andcommitted
net: hibmcge: fix wrong ndo.open() after reset fail issue.
If the driver reset fails, it may not work properly. Therefore, the ndo.open() operation should be rejected. In this patch, the driver calls netif_device_detach() before the reset and calls netif_device_attach() after the reset succeeds. If the reset fails, netif_device_attach() is not called. Therefore, netdev does not present and cannot be opened. If reset fails, only the PCI reset (via sysfs) can be used to attempt recovery. Fixes: 3f5a61f ("net: hibmcge: Add reset supported in this module") Signed-off-by: Jijie Shao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0099705 commit 1b45443

File tree

1 file changed

+8
-8
lines changed
  • drivers/net/ethernet/hisilicon/hibmcge

1 file changed

+8
-8
lines changed

drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ static int hbg_reset_prepare(struct hbg_priv *priv, enum hbg_reset_type type)
6161
return -EBUSY;
6262
}
6363

64+
netif_device_detach(priv->netdev);
65+
6466
priv->reset_type = type;
6567
set_bit(HBG_NIC_STATE_RESETTING, &priv->state);
6668
clear_bit(HBG_NIC_STATE_RESET_FAIL, &priv->state);
@@ -91,6 +93,8 @@ static int hbg_reset_done(struct hbg_priv *priv, enum hbg_reset_type type)
9193
return ret;
9294
}
9395

96+
netif_device_attach(priv->netdev);
97+
9498
dev_info(&priv->pdev->dev, "reset done\n");
9599
return ret;
96100
}
@@ -117,16 +121,13 @@ void hbg_err_reset(struct hbg_priv *priv)
117121
if (running)
118122
dev_close(priv->netdev);
119123

120-
hbg_reset(priv);
121-
122-
/* in hbg_pci_err_detected(), we will detach first,
123-
* so we need to attach before open
124-
*/
125-
if (!netif_device_present(priv->netdev))
126-
netif_device_attach(priv->netdev);
124+
if (hbg_reset(priv))
125+
goto err_unlock;
127126

128127
if (running)
129128
dev_open(priv->netdev, NULL);
129+
130+
err_unlock:
130131
rtnl_unlock();
131132
}
132133

@@ -160,7 +161,6 @@ static pci_ers_result_t hbg_pci_err_slot_reset(struct pci_dev *pdev)
160161
pci_save_state(pdev);
161162

162163
hbg_err_reset(priv);
163-
netif_device_attach(netdev);
164164
return PCI_ERS_RESULT_RECOVERED;
165165
}
166166

0 commit comments

Comments
 (0)