From: Michael Baum Date: Sun, 12 Sep 2021 10:36:28 +0000 (+0300) Subject: common/mlx5: fix resource cleaning in device removal X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dffae63d3c0157eb1c3b7cd4aad4b0048455be60;p=dpdk.git common/mlx5: fix resource cleaning in device removal The common remove function call in a loop to remove function for each driver which have been registered. If all removes are succeeded, it return 0 without to free the device which allocated in probe function. Otherwise, it free the device. In fact we expect exactly the opposite behavior. If all removes are failed, it returns error without freeing the device which allocated in probe function. Otherwise, it free the device and return 0. Replace it with the correct behavior. Fixes: 8a41f4deccc3 ("common/mlx5: introduce layer for multiple class drivers") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index 4321cb3a9c..6885bbb1d2 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -354,7 +354,7 @@ mlx5_common_dev_remove(struct rte_device *eal_dev) return -ENODEV; /* Matching device found, cleanup and unload drivers. */ ret = drivers_remove(dev, dev->classes_loaded); - if (ret != 0) + if (ret == 0) dev_release(dev); return ret; }