net/cpfl: fix memory leak
PATCH 1/1 net/cpfl: fix memory leak
From: Beilei Xing <[email protected]>
Fix resource leak reported in coverity scan.
Coverity issue: 403265
--- drivers/net/cpfl/cpfl_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/cpfl/cpfl_ethdev.c +3 -2
@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapif (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
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 leakFrom: 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")Signed-off-by Beilei Xing <[email protected]>--- drivers/net/cpfl/cpfl_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/cpfl/cpfl_ethdev.c +0
-0@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev,struct
cpfl_adapter_ext*adapdrivers/net/cpfl/cpfl_ethdev.c +2
-1if (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(structrte_pci_device*pci_dev, structcpfl_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
-1goto 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
-1ret =rte_kvargs_process (kvlist,CPFL_VPORT , &parse_vport, cpfl_args); --2.34.1
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
---
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
@@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapif (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
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 leakFrom: 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")Signed-off-by Beilei Xing <[email protected]>
Applied to dpdk-next-net-intel.
Thanks
Qi