Skip to contentSkip to conversation

net/cpfl: fix memory leak

PATCH Superseded [email protected] 2 participants 4 messages Oct 17, 2023 – Oct 19, 2023 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/cpfl: fix memory leak

From: Beilei Xing <[email protected]>

Fix resource leak reported in coverity scan.

Coverity issue: 403265

Fixes 2d823ecd671c ("net/cpfl: support device initialization")
Fixes 989465ac51ea ("net/cpfl: support probe again")
---
 drivers/net/cpfl/cpfl_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +3 -2
index 890a027a1d..0093deab5a 100644
@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
 
 	if (rte_kvargs_count(kvlist, CPFL_VPORT) > 1) {
 		PMD_INIT_LOG(ERR, "devarg vport is duplicated.");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto fail;
 	}
 
 	ret = rte_kvargs_process(kvlist, CPFL_REPRESENTOR, &parse_repr, cpfl_args);
@@ -1635,7 +1636,7 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
 		goto fail;
 
 	if (!first)
-		return 0;
+		goto fail;
 
 	ret = rte_kvargs_process(kvlist, CPFL_VPORT, &parse_vport,
 				 cpfl_args);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 40 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, October 17, 2023 7:07 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>; [email protected]
Subject: [PATCH] net/cpfl: fix memory leak

From: Beilei Xing <[email protected]>

Fix resource leak reported in coverity scan.

Coverity issue: 403265

Fixes 2d823ecd671c ("net/cpfl: support device initialization")
Fixes 989465ac51ea ("net/cpfl: support probe again")
---
 drivers/net/cpfl/cpfl_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +0 -0
index 890a027a1d..0093deab5a 100644
@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev,

struct cpfl_adapter_ext *adap

drivers/net/cpfl/cpfl_ethdev.c +2 -1
 	if (rte_kvargs_count(kvlist, CPFL_VPORT) > 1) {
 		PMD_INIT_LOG(ERR, "devarg vport is duplicated.");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto fail;
 	}
 
 	ret = rte_kvargs_process(kvlist, CPFL_REPRESENTOR, &parse_repr,

cpfl_args); @@ -1635,7 +1636,7 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap

drivers/net/cpfl/cpfl_ethdev.c cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap · line 1639

Quoted 5 lines
drivers/net/cpfl/cpfl_ethdev.c +1 -1
 		goto fail;
 
 	if (!first)
-		return 0;
+		goto fail;

goto fail in a success case cause confusion, maybe we can rename "fail" as "finish", or adding a another label right before "fail"?

Quoted 5 lines
drivers/net/cpfl/cpfl_ethdev.c +0 -1
 	ret = rte_kvargs_process(kvlist, CPFL_VPORT, &parse_vport,
 				 cpfl_args);
--

2.34.1

#2 lore raw

PATCH v2 1/1 net/cpfl: fix memory leak

In reply to [email protected]

From: Beilei Xing <[email protected]>

Fix resource leak reported in coverity scan.

Coverity issue: 403265

Fixes 2d823ecd671c ("net/cpfl: support device initialization")
Fixes 989465ac51ea ("net/cpfl: support probe again")

---
v2 change:
- add label finish for successful case.

 drivers/net/cpfl/cpfl_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +4 -2
index 890a027a1d..a94a0604f5 100644
@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
 
 	if (rte_kvargs_count(kvlist, CPFL_VPORT) > 1) {
 		PMD_INIT_LOG(ERR, "devarg vport is duplicated.");
-		return -EINVAL;
+		ret = -EINVAL;
+		goto fail;
 	}
 
 	ret = rte_kvargs_process(kvlist, CPFL_REPRESENTOR, &parse_repr, cpfl_args);
@@ -1635,7 +1636,7 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
 		goto fail;
 
 	if (!first)
-		return 0;
+		goto finish;
 
 	ret = rte_kvargs_process(kvlist, CPFL_VPORT, &parse_vport,
 				 cpfl_args);
@@ -1663,6 +1664,7 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
 		cpfl_args->flow_parser[0] = '\0';
 	}
 #endif
+finish:
 fail:
 	rte_kvargs_free(kvlist);
 	return ret;
Signature · 1 line
2.34.1
Acked-by on v2 1/1 Applied
#3 lore raw
Quoted 12 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Wednesday, October 18, 2023 10:27 PM
To: Wu, Jingjing <[email protected]>; Zhang, Yuying <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>; [email protected]
Subject: [PATCH v2] net/cpfl: fix memory leak

From: Beilei Xing <[email protected]>

Quoted 8 lines

Fix resource leak reported in coverity scan.

Coverity issue: 403265

Fixes 2d823ecd671c ("net/cpfl: support device initialization")
Fixes 989465ac51ea ("net/cpfl: support probe again")

Applied to dpdk-next-net-intel.

Thanks
Qi