net: mana: Fix debugfs directory naming and file lifecycle
cover net: mana: Fix debugfs directory naming and file lifecycle
This series fixes two pre-existing debugfs issues in the MANA driver.
Patch 1 fixes the per-device debugfs directory naming to use the unique PCI BDF address via pci_name(), avoiding a potential NULL pointer dereference when pdev->slot is NULL (e.g. VFIO passthrough, nested KVM) and preventing name collisions across multiple PFs or VFs.
Patch 2 moves the current_speed debugfs file creation from mana_probe_port() to mana_init_port() so it survives detach/attach cycles triggered by MTU changes or XDP program changes.
Erni Sri Satya Vennela (2):
net: mana: Use pci_name() for debugfs directory naming
net: mana: Move current_speed debugfs file to mana_init_port()
drivers/net/ethernet/microsoft/mana/gdma_main.c | 7 ++----- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 net: mana: Use pci_name() for debugfs directory naming
Use pci_name(pdev) for the per-device debugfs directory instead of hardcoded "0" for PFs and pci_slot_name(pdev->slot) for VFs. The previous approach had two issues:
1. pci_slot_name() dereferences pdev->slot, which can be NULL for VFs in environments like generic VFIO passthrough or nested KVM, causing a NULL pointer dereference.
2. Multiple PFs would all use "0", and VFs across different PCI domains or buses could share the same slot name, leading to -EEXIST errors from debugfs_create_dir().
pci_name(pdev) returns the unique BDF address, is always valid, and is unique across the system.
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +2 -5
@@ -2065,11 +2065,8 @@ static int mana_gd_probe(struct pci_dev *pdev, const struct pci_device_id *ent) gc->dev = &pdev->dev;xa_init (&gc->irq_contexts); -if (gc->is_pf) - gc->mana_pci_debugfs =debugfs_create_dir ("0" , mana_debugfs_root); -else - gc->mana_pci_debugfs =debugfs_create_dir (pci_slot_name (pdev->slot), - mana_debugfs_root); + gc->mana_pci_debugfs =debugfs_create_dir (pci_name (pdev), + mana_debugfs_root); err =mana_gd_setup (pdev);if (err)
Signature · 1 line
2.34.1
Re: [PATCH net 1/2] net: mana: Use pci_name() for debugfs directory naming
Quoted 12 lines · Erni Sri Satya Vennela
Use
pci_name(pdev)for the per-device debugfs directory instead of hardcoded "0" for PFs andpci_slot_name(pdev->slot)for VFs. The previous approach had two issues:1.
pci_slot_name()dereferencespdev->slot, which can be NULL for VFs in environments like generic VFIO passthrough or nested KVM, causing a NULL pointer dereference.2. Multiple PFs would all use "0", and VFs across different PCI domains or buses could share the same slot name, leading to
-EEXISTerrors fromdebugfs_create_dir().
Quoted 5 lines
pci_name(pdev)returns the unique BDF address, is always valid, and is unique across the system.Fixes 6607c17c6c5e ("net: mana: Enable debugfs files for MANA device")Signed-off-by Erni Sri Satya Vennela <[email protected]>
PATCH 2/2 net: mana: Move current_speed debugfs file to mana_init_port()
In reply to Erni Sri Satya VennelaMove the current_speed debugfs file creation from mana_probe_port() to mana_init_port(). The file was previously created only during initial probe, but mana_cleanup_port_context() removes the entire vPort debugfs directory during detach/attach cycles. Since mana_init_port() recreates the directory on re-attach, moving current_speed here ensures it survives these cycles.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -2
@@ -3154,6 +3154,8 @@ static int mana_init_port(struct net_device *ndev)eth_hw_addr_set (ndev, apc->mac_addr);sprintf (vport,"vport%d" , port_idx); apc->mana_port_debugfs =debugfs_create_dir (vport, gc->mana_pci_debugfs); +debugfs_create_u32 ("current_speed" ,0400 , apc->mana_port_debugfs, + &apc->speed);return 0 ; reset_apc:
@@ -3432,8 +3434,6 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,netif_carrier_on (ndev); -debugfs_create_u32 ("current_speed" ,0400 , apc->mana_port_debugfs, &apc->speed); -return 0 ; free_indir:
Signature · 1 line
2.34.1
Re: [PATCH net 2/2] net: mana: Move current_speed debugfs file to mana_init_port()
Quoted 9 lines · Erni Sri Satya Vennela
Move the
current_speeddebugfs file creation frommana_probe_port()tomana_init_port(). The file was previously created only during initial probe, butmana_cleanup_port_context()removes the entire vPort debugfs directory during detach/attach cycles. Sincemana_init_port()recreates the directory on re-attach, movingcurrent_speedhere ensures it survives these cycles.Fixes 75cabb46935b ("net: mana: Add support for net_shaper_ops")Signed-off-by Erni Sri Satya Vennela <[email protected]>
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 8 Apr 2026 01:12:18 -0700 you wrote:
This series fixes two pre-existing debugfs issues in the MANA driver.
Patch 1 fixes the per-device debugfs directory naming to use the unique PCI BDF address via
pci_name(), avoiding a potential NULL pointer dereference whenpdev->slotis NULL (e.g. VFIO passthrough, nested KVM) and preventing name collisions across multiple PFs or VFs.[...]
Here is the summary with links:
- [net,1/2] net: mana: Use pci_name() for debugfs directory naming
https://git.kernel.org/netdev/net/c/c116f07ab9d2 - [net,2/2] net: mana: Move current_speed debugfs file to mana_init_port() https://git.kernel.org/netdev/net/c/3b7c7fc97aea
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html