diff mbox series

[v4,1/8] net/mlx5: fix flow counters creation

Message ID 1540289032-29628-2-git-send-email-viacheslavo@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Shahaf Shuler
Headers show
Series [v4,1/8] net/mlx5: fix flow counters creation | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Slava Ovsiienko Oct. 23, 2018, 10:04 a.m. UTC
The Flow counter creation function contains two problems:

  - Flow counter object in Verbs is not freed in case of memory
    allocation error. The call of counter Verbs object deallocating
    function is added to fix.

  - The initial value of reference counter is set to one in order
    to provide the correct counter object freeing in the
    flow_verbs_counter_release() function. The reference counter
    field should be initialized to one.

Fixes: 60bd8c9747e8 ("net/mlx5: add count flow action")
Cc: stable@dpdk.org

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_verbs.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index 4ae974b..6ddb13b 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -72,6 +72,7 @@ 
 			 }),
 		.hits = 0,
 		.bytes = 0,
+		.ref_cnt = 1,
 	};
 
 	if (!tmpl.cs) {
@@ -80,6 +81,7 @@ 
 	}
 	cnt = rte_calloc(__func__, 1, sizeof(*cnt), 0);
 	if (!cnt) {
+		claim_zero(mlx5_glue->destroy_counter_set(tmpl.cs));
 		rte_errno = ENOMEM;
 		return NULL;
 	}