From: Paolo Abeni <pabeni@redhat.com>
To: han.junyang@zte.com.cn
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
ran.ming@zte.com.cn, han.chengfei@zte.com.cn,
zhang.yanze@zte.com.cn
Subject: Re: [PATCH net-next v7 1/2] dinghai: add ZTE network driver support
Date: Fri, 3 Jul 2026 18:42:32 +0200 [thread overview]
Message-ID: <20260703164232.336162-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260630111300830lukBczfNSgWE5wt6qR95k@zte.com.cn>
From: AI Reviewer <ai@example.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev/
---
dinghai: add ZTE network driver support
Add basic framework for ZTE DingHai ethernet PF driver, including
Kconfig/Makefile build support and PCIe device probe/remove skeleton.
> diff --git a/drivers/net/ethernet/zte/dinghai/en_pf.c b/drivers/net/ethernet/zte/dinghai/en_pf.c
> new file mode 100644
> index 0000000000000..b492fd2c261b8
> --- /dev/null
> +++ b/drivers/net/ethernet/zte/dinghai/en_pf.c
[ ... ]
> +static int dh_pf_pci_init(struct dh_core_dev *dev)
> +{
> + struct zxdh_pf_device *pf_dev = dev->priv;
> + int ret;
[ ... ]
> + pf_dev->pci_ioremap_addr[0] =
> + ioremap(pci_resource_start(dev->pdev, 0),
> + pci_resource_len(dev->pdev, 0));
[Severity: Medium]
Should this check if BAR 0 is actually an IORESOURCE_MEM before mapping it?
Calling ioremap() on an I/O port address or an unpopulated BAR could map
arbitrary physical memory.
Would it be safer to use pci_ioremap_bar() or pcim_iomap() which enforce
resource type and length checks?
> + if (!pf_dev->pci_ioremap_addr[0]) {
> + ret = -ENOMEM;
> + dev_err(dev->device, "dh pf pci ioremap failed\n");
> + goto err_pci_save_state;
> + }
[ ... ]
> +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;
> +
> + devlink_unregister(devlink);
> + 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);
> + pci_set_drvdata(pdev, NULL);
> +}
> +
> +static void dh_pf_shutdown(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;
> +
> + devlink_unregister(devlink);
> + 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);
> + pci_set_drvdata(pdev, NULL);
> +}
[Severity: High]
Does this destructive teardown in the .shutdown callback create a race if
.remove is called afterwards?
If .remove is triggered (for example, during a hot-remove event during
shutdown), pci_get_drvdata() in dh_pf_remove() will return NULL.
The macro priv_to_devlink() will then convert NULL into a bad pointer,
causing a panic in devlink_unregister().
Should .shutdown only quiesce the hardware without destroying software
structures?
--
This is an AI-generated review.
next prev parent reply other threads:[~2026-07-03 16:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 3:09 [PATCH net-next v7 0/2] Add ZTE DingHai Ethernet PF driver han.junyang
2026-06-30 3:13 ` [PATCH net-next v7 1/2] dinghai: add ZTE network driver support han.junyang
2026-07-02 19:35 ` Julian Braha
2026-07-03 16:42 ` Paolo Abeni [this message]
2026-06-30 3:15 ` [PATCH net-next v7 2/2] dinghai: add hardware register access and PCI capability scanning han.junyang
2026-07-03 16:42 ` Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260703164232.336162-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=han.chengfei@zte.com.cn \
--cc=han.junyang@zte.com.cn \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ran.ming@zte.com.cn \
--cc=zhang.yanze@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox