net/mlx5: fix jump table leak
authorSuanming Mou <suanmingm@mellanox.com>
Mon, 13 Apr 2020 13:29:13 +0000 (21:29 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:08 +0000 (13:57 +0200)
Currently, when translate jump action, the table reference will be
increased all the time. But when release the jump action, the table
resource reference will only be decreased when jump action is released.
It means for jump action which was referenced more than one time, the
increased table reference only decrease one time when jump action is
released.

Add table release when the jump action was not new created.

Fixes: 684b9a1b1f5c ("net/mlx5: support jump action")
Cc: stable@dpdk.org
Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index 0676b6f..e87e30f 100644 (file)
@@ -73,6 +73,10 @@ union flow_dv_attr {
        uint32_t attr;
 };
 
+static int
+flow_dv_tbl_resource_release(struct rte_eth_dev *dev,
+                            struct mlx5_flow_tbl_resource *tbl);
+
 /**
  * Initialize flow attributes structure according to flow items' types.
  *
@@ -2530,6 +2534,8 @@ flow_dv_jump_tbl_resource_register
                DRV_LOG(DEBUG, "new jump table resource %p: refcnt %d++",
                        (void *)&tbl_data->jump, cnt);
        } else {
+               /* old jump should not make the table ref++. */
+               flow_dv_tbl_resource_release(dev, &tbl_data->tbl);
                MLX5_ASSERT(tbl_data->jump.action);
                DRV_LOG(DEBUG, "existed jump table resource %p: refcnt %d++",
                        (void *)&tbl_data->jump, cnt);