net/mlx5: fix RxQ resource cleanup

Message ID 20211018172456.3335320-1-dkozlyuk@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix RxQ resource cleanup |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Dmitry Kozlyuk Oct. 18, 2021, 5:24 p.m. UTC
  mlx5_rxq_start() allocates rxq_ctrl->obj and frees it on failure,
but did not set it to NULL. Later mlx5_rxq_release() could not recognize
this object is already freed and attempted to release its resources,
resulting in a crash:

    Configuring Port 0 (socket 0)
    mlx5_common: Failed to create RQ using DevX
    mlx5_common: Can't create DevX RQ object.
    mlx5_net: Port 0 Rx queue 0 RQ creation failure.
    Segmentation fault

Set rxq_ctrl->obj to NULL after it is freed to skip resource release.

Fixes: 1260a87b2889 ("net/mlx5: share Rx control code")
Cc: Michael Baum <michaelba@nvidia.com>
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_trigger.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Raslan Darawsheh Oct. 20, 2021, 7:35 p.m. UTC | #1
Hi,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dmitry Kozlyuk
> Sent: Monday, October 18, 2021 8:25 PM
> To: dev@dpdk.org
> Cc: Michael Baum <michaelba@oss.nvidia.com>; stable@dpdk.org; Matan
> Azrad <matan@oss.nvidia.com>; Viacheslav Ovsiienko
> <viacheslavo@oss.nvidia.com>
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix RxQ resource cleanup
> 
> mlx5_rxq_start() allocates rxq_ctrl->obj and frees it on failure, but did not
> set it to NULL. Later mlx5_rxq_release() could not recognize this object is
> already freed and attempted to release its resources, resulting in a crash:
> 
>     Configuring Port 0 (socket 0)
>     mlx5_common: Failed to create RQ using DevX
>     mlx5_common: Can't create DevX RQ object.
>     mlx5_net: Port 0 Rx queue 0 RQ creation failure.
>     Segmentation fault
> 
> Set rxq_ctrl->obj to NULL after it is freed to skip resource release.
> 
> Fixes: 1260a87b2889 ("net/mlx5: share Rx control code")
> Cc: Michael Baum <michaelba@nvidia.com>
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 54173bfacb..0ecdd776fc 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -182,6 +182,7 @@  mlx5_rxq_start(struct rte_eth_dev *dev)
 		ret = priv->obj_ops.rxq_obj_new(dev, i);
 		if (ret) {
 			mlx5_free(rxq_ctrl->obj);
+			rxq_ctrl->obj = NULL;
 			goto error;
 		}
 		DRV_LOG(DEBUG, "Port %u rxq %u updated with %p.",