Skip to contentSkip to conversation

pvrdma: release device resources in case of an error

PATCH In review P J P 2 participants 2 messages Dec 12, 2018

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 pvrdma: release device resources in case of an error

From: Prasad J Pandit <[email protected]>

If during pvrdma device initialisation an error occurs, pvrdma_realize() does not release memory resources, leading to memory leakage.

---
 hw/rdma/vmw/pvrdma_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/rdma/vmw/pvrdma_main.c +2 -1
index 8a03ab4669..b65f8662df 100644
@@ -579,7 +579,7 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
 
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
-    int rc;
+    int rc = 0;
     PVRDMADev *dev = PVRDMA_DEV(pdev);
     Object *memdev_root;
     bool ram_shared = false;
@@ -655,6 +655,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 
 out:
     if (rc) {
+        pvrdma_fini(pdev);
         error_append_hint(errp, "Device fail to load\n");
     }
 }
Signature · 1 line
2.19.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · P J P

From: Prasad J Pandit <[email protected]>

If during pvrdma device initialisation an error occurs, pvrdma_realize() does not release memory resources, leading to memory leakage.

---
 hw/rdma/vmw/pvrdma_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/rdma/vmw/pvrdma_main.c +1 -1
index 8a03ab4669..b65f8662df 100644
@@ -579,7 +579,7 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque)
 
 static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 {
-    int rc;
+    int rc = 0;
     PVRDMADev *dev = PVRDMA_DEV(pdev);
     Object *memdev_root;
     bool ram_shared = false;

hw/rdma/vmw/pvrdma_main.c static void pvrdma_realize(PCIDevice *pdev, Error **errp) · line 660

Quoted 6 lines
hw/rdma/vmw/pvrdma_main.c +1 -0
@@ -655,6 +655,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp)
 
 out:
     if (rc) {
+        pvrdma_fini(pdev);
         error_append_hint(errp, "Device fail to load\n");
     }

Thanks.

Quoted 4 lines
hw/rdma/vmw/pvrdma_main.c +0 -0
 }
Signature · 1 line
2.19.2