Re: [PATCH net-next v5 1/2] dinghai: add ZTE network driver support
From: Andrew Lunn
Date: Mon Jun 01 2026 - 10:35:36 EST
> +static void dh_pf_remove(struct pci_dev *pdev)
> +{
> + struct dh_core_dev *dh_dev = pci_get_drvdata(pdev);
> + struct devlink *devlink = priv_to_devlink(dh_dev);
> + struct zxdh_pf_device *pf_dev = dh_dev->priv;
> +
> + dev_info(&pdev->dev, "dh_pf remove start\n");
> +
> + dh_pf_pci_close(dh_dev);
> + mutex_destroy(&pf_dev->irq_lock);
> + mutex_destroy(&dh_dev->lock);
> + dh_core_free_priv(dh_dev);
> + devlink_free(devlink);
Think about the ordering. What does that devlink instance allow? At
some point you are going to add some ops. Do any of those ops need to
access the PCI device? Do they need the mutex? Access to priv?
> +static inline void dh_core_free_priv(struct dh_core_dev *dh_dev)
> +{
> + kfree(dh_dev->priv);
> + dh_dev->priv = NULL;
There should not be any need to set it to NULL. If you have called
dh_core_free_priv() you should be 100% sure you will not be accessing
it again.
Andrew