Re: [PATCH V3 net-next 02/11] net: hibmcge: Add read/write registers supported through the bar space
From: Andrew Lunn <andrew@lunn.ch>
Date: 2024-08-22 16:05:00
Also in:
lkml
From: Andrew Lunn <andrew@lunn.ch>
Date: 2024-08-22 16:05:00
Also in:
lkml
static int hbg_pci_init(struct pci_dev *pdev) {@@ -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);
There is a potential race here. Before devm_register_netdev() even 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