Skip to contentSkip to conversation

vdpa: ifcvf: Do proper cleanup if IFCVF init fails

PATCH In review Tanmay Bhushan 4 participants 4 messages Dec 27, 2022 – Jan 27, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vdpa: ifcvf: Do proper cleanup if IFCVF init fails

From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
From: Tanmay Bhushan <[email protected]>
Date: Tue, 27 Dec 2022 22:02:16 +0100
Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails

ifcvf_mgmt_dev leaks memory if it is not freed before returning. Call is made to correct return statement so memory does not leak. ifcvf_init_hw does not take care of this so it is needed to do it here.

---
 drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/vdpa/ifcvf/ifcvf_main.c
index f9c0044c6442..44b29289aa19 100644

drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
@@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const

struct pci_device_id *id)
ret = ifcvf_init_hw(vf, pdev);
if (ret) {
IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
- return ret;
+ goto err;
}

for (i = 0; i < vf->nr_vring; i++)

Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tanmay Bhushan

From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
From: Tanmay Bhushan <[email protected]>
Date: Tue, 27 Dec 2022 22:02:16 +0100
Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails

Quoted 6 lines

ifcvf_mgmt_dev leaks memory if it is not freed before returning. Call is made to correct return statement so memory does not leak. ifcvf_init_hw does not take care of this so it is needed to do it here.

Thanks

Quoted 19 lines
---
 drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/ifcvf/ifcvf_main.c +1 -1
index f9c0044c6442..44b29289aa19 100644
@@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
 struct pci_device_id *id)
        ret = ifcvf_init_hw(vf, pdev);
        if (ret) {
                IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
-               return ret;
+               goto err;
        }
 
        for (i = 0; i < vf->nr_vring; i++)
Quoted 4 lines

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Acked-by
#2 lore raw
Quoted 11 lines · Jason Wang
Quoted 10 lines · Tanmay Bhushan

From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001
From: Tanmay Bhushan <[email protected]>
Date: Tue, 27 Dec 2022 22:02:16 +0100
Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails

ifcvf_mgmt_dev leaks memory if it is not freed before returning. Call is made to correct return statement so memory does not leak. ifcvf_init_hw does not take care of this so it is needed to do it here.

Quoted 4 lines
Quoted 1 line

Thanks

Thanks

Quoted 19 lines
Quoted 19 lines
---
  drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/ifcvf/ifcvf_main.c +1 -1
index f9c0044c6442..44b29289aa19 100644
@@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
 struct pci_device_id *id)
         ret = ifcvf_init_hw(vf, pdev);
         if (ret) {
                 IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
-               return ret;
+               goto err;
         }
 
Quoted 5 lines
Quoted 5 lines
         for (i = 0; i < vf->nr_vring; i++)

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
In reply to Tanmay Bhushan
Quoted 21 lines · Tanmay Bhushan
Quoted 1 line

From 7eae04667ddaac8baa4812d48ef2c942cedef946 Mon Sep 17 00:00:00 2001

From: Tanmay Bhushan <[email protected]>
Date: Tue, 27 Dec 2022 22:02:16 +0100
Subject: [PATCH] vdpa: ifcvf: Do proper cleanup if IFCVF init fails

ifcvf_mgmt_dev leaks memory if it is not freed before returning. Call is made to correct return statement so memory does not leak. ifcvf_init_hw does not take care of this so it is needed to do it here.

---
 drivers/vdpa/ifcvf/ifcvf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
index f9c0044c6442..44b29289aa19 100644

drivers/vdpa/ifcvf/ifcvf_main.c static int ifcvf_probe(struct pci_dev *pdev, const · line 849

Quoted 1 line
drivers/vdpa/ifcvf/ifcvf_main.c +0 -0
@@ -849,7 +849,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const
 struct pci_device_id *id)

BTW your patch was mangled but I fixed it.

Quoted 11 lines
drivers/vdpa/ifcvf/ifcvf_main.c +1 -1
 	ret = ifcvf_init_hw(vf, pdev);
 	if (ret) {
 		IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
-		return ret;
+		goto err;
 	}
 

for (i = 0; i < vf->nr_vring; i++)

Signature · 1 line
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization