From: Long Li <[email protected]>

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: [email protected]

Signed-off-by: Long Li <[email protected]>
---
 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..6f70a6d774 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) {
+               ret = ibv_dealloc_pd(priv->ib_parent_pd);
+               if (ret)
+                       DRV_LOG(ERR, "Failed to deallocate parent PD: %d", ret);
+               priv->ib_parent_pd = NULL;
+       }
+
+       if (priv->ib_pd) {
+               ret = ibv_dealloc_pd(priv->ib_pd);
+               if (ret)
+                       DRV_LOG(ERR, "Failed to deallocate PD: %d", ret);
+               priv->ib_pd = NULL;
+       }
+
        ret = ibv_close_device(priv->ib_ctx);
        if (ret) {
                ret = errno;
-- 
2.43.0

Reply via email to