static int hbg_pci_init(struct pci_dev *pdev)There is a potential race here. Before devm_register_netdev() even
{
@@ -56,10 +62,15 @@ static int hbg_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
return ret;
+ ret = hbg_init(priv);
+ if (ret)
+ return ret;
+
ret = devm_register_netdev(dev, netdev);
if (ret)
return dev_err_probe(dev, ret, "failed to register netdev\n");
+ set_bit(HBG_NIC_STATE_INITED, &priv->state);
returns, the linux stack could be sending packets. You need to ensure
nothing actual needs HBG_NIC_STATE_INITED when the interface is
operating, because it might not be set yet.
In general, such state variables are not needed. If registration
failed, probe failed, and the driver will be unloaded. If registration
succeeded and other functions are being used, registration must of
been successful.
Andrew