[PATCH v5 3/7] net/mana: fix PD resource leak on device close

Long Li
2026-02-27T02:00:01Z

The Protection Domains (PDs) allocated during device initialization
were not being deallocated on device close, causing a resource leak.

Deallocate both ib_parent_pd and ib_pd in mana_dev_close() before
closing the IB device context. Log errors if deallocation fails,
which would indicate orphaned child resources (QPs, MRs). The close
proceeds regardless because ibv_close_device() will force kernel
cleanup of any remaining resources.

Fixes: 2f5749ead13a ("net/mana: add basic driver with build environment")
Cc: stable@dpdk.org

Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/net/mana/mana.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index b7ae01b152..67396cda1f 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -282,6 +282,20 @@ mana_dev_close(struct rte_eth_dev *dev)
if (ret)
return ret;

+ if (priv->ib_parent_pd) {
+ int err = ibv_dealloc_pd(priv->ib_parent_pd);
+ if (err)
+ DRV_LOG(ERR, "Failed to deallocate parent PD: %d", err);
+ priv->ib_parent_pd = NULL;
+ }
+
+ if (priv->ib_pd) {
+ int err = ibv_dealloc_pd(priv->ib_pd);
+ if (err)
+ DRV_LOG(ERR, "Failed to deallocate PD: %d", err);
+ priv->ib_pd = NULL;
+ }
+
ret = ibv_close_device(priv->ib_ctx);
if (ret) {
ret = errno;
--
2.43.0