Skip to contentSkip to conversation

vdpa/mlx5: fix RSS flow leak on steering update failure

PATCH Applied Maayan Kashani 2 participants 4 messages Oct 25 – Nov 10

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

PATCH 1/2 vdpa/mlx5: fix RSS flow leak on steering update failure

mlx5_vdpa_steer_update() calls mlx5_vdpa_rss_flows_create() which, on failure, leaves behind any RSS steering objects (matcher, TIR, TIR action, flow) it managed to create before the error, relying on the caller to release them.

mlx5_vdpa_steer_setup() honors that contract by calling mlx5_vdpa_steer_unset() on its error path, but mlx5_vdpa_virtq_enable() only logs a warning and continues when mlx5_vdpa_steer_update() fails. As a result, every failed steering update triggered from the virtq enable/disable path leaks the partially created software-steering objects. Over many reconfiguration cycles this exhausts the kernel software-steering (DR) resources and later probes fail with "Failed to create Rx domain".

Free the partial RSS flows in mlx5_vdpa_steer_update() itself so that all callers are covered regardless of how they handle the return value. mlx5_vdpa_rss_flows_destroy() checks each object for NULL, so the subsequent steer_unset() on the steer_setup() error path stays a safe no-op.

Fixes 9f09b1ca15c5 ("vdpa/mlx5: recreate a virtq becoming enabled")
---
 drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vdpa/mlx5/mlx5_vdpa_steer.c +1 -0
index c2e0a17ace2..b1bca7f0f7d 100644
@@ -255,6 +255,7 @@ mlx5_vdpa_steer_update(struct mlx5_vdpa_priv *priv, bool is_dummy)
 		ret = mlx5_vdpa_rss_flows_create(priv);
 		if (ret) {
 			DRV_LOG(ERR, "Cannot create RSS flows.");
+			mlx5_vdpa_rss_flows_destroy(priv);
 			pthread_mutex_unlock(&priv->steer_update_lock);
 			return -1;
 		}
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 vdpa/mlx5: fix RQT attributes memory leak

mlx5_vdpa_rqt_prepare() allocates RQT attributes with rte_zmalloc() but returns without freeing them when no enabled receive queue is found (k == 0). Every steering update that hits this path leaks the allocation.

Free attr before returning on the no-enabled-RQ path.

Fixes 9f09b1ca15c5 ("vdpa/mlx5: recreate a virtq becoming enabled")
---
 drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vdpa/mlx5/mlx5_vdpa_steer.c +3 -1
index b1bca7f0f7d..5dd9ca40ebc 100644
@@ -85,9 +85,11 @@ mlx5_vdpa_rqt_prepare(struct mlx5_vdpa_priv *priv, bool is_dummy)
 			k++;
 		}
 	}
-	if (k == 0)
+	if (k == 0) {
 		/* No enabled RQ to configure for RSS. */
+		rte_free(attr);
 		return 0;
+	}
 	num = (int)k;
 	for (j = 0; k != rqt_n; ++k, ++j)
 		attr->rq_list[k] = attr->rq_list[j];
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] vdpa/mlx5: fix RQT attributes memory leak

Quoted 8 lines · Maayan Kashani

mlx5_vdpa_rqt_prepare() allocates RQT attributes with rte_zmalloc() but returns without freeing them when no enabled receive queue is found (k == 0). Every steering update that hits this path leaks the allocation.

Free attr before returning on the no-enabled-RQ path.

Quoted 9 lines
Fixes 9f09b1ca15c5 ("vdpa/mlx5: recreate a virtq becoming enabled")
---
 drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to next-virtio/for-next-net.

Thanks,
Maxime

#3 lore raw
In reply to Maayan Kashani
Quoted 21 lines · Maayan Kashani

mlx5_vdpa_steer_update() calls mlx5_vdpa_rss_flows_create() which, on failure, leaves behind any RSS steering objects (matcher, TIR, TIR action, flow) it managed to create before the error, relying on the caller to release them.

mlx5_vdpa_steer_setup() honors that contract by calling mlx5_vdpa_steer_unset() on its error path, but mlx5_vdpa_virtq_enable() only logs a warning and continues when mlx5_vdpa_steer_update() fails. As a result, every failed steering update triggered from the virtq enable/disable path leaks the partially created software-steering objects. Over many reconfiguration cycles this exhausts the kernel software-steering (DR) resources and later probes fail with "Failed to create Rx domain".

Free the partial RSS flows in mlx5_vdpa_steer_update() itself so that all callers are covered regardless of how they handle the return value. mlx5_vdpa_rss_flows_destroy() checks each object for NULL, so the subsequent steer_unset() on the steer_setup() error path stays a safe no-op.

Quoted 9 lines
Fixes 9f09b1ca15c5 ("vdpa/mlx5: recreate a virtq becoming enabled")
---
 drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 1 +
 1 file changed, 1 insertion(+)

Applied to next-virtio/for-next-net.

Thanks,
Maxime