]> git.droids-corp.org - dpdk.git/commitdiff
common/mlx5: fix probing failure code
authorBing Zhao <bingz@nvidia.com>
Mon, 17 Jan 2022 17:49:14 +0000 (19:49 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Wed, 26 Jan 2022 16:41:12 +0000 (17:41 +0100)
While probing the device with unsupported class, the process should
fail because no appropriate driver was found. After traversing all
the drivers, an error value should be returned for the case.

In the previous implementation, zero value indicating probing success
was wrongly returned.

Fixes: ad435d320473 ("common/mlx5: add bus-agnostic layer")
Cc: stable@dpdk.org
Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/common/mlx5/mlx5_common.c

index 185db4d00410cb8804e593c5c7fa2c1faa6dc672..47a541f5efb673d6828d5c5caaceea3c7d071925 100644 (file)
@@ -644,7 +644,7 @@ drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes)
        struct mlx5_class_driver *driver;
        uint32_t enabled_classes = 0;
        bool already_loaded;
-       int ret;
+       int ret = -EINVAL;
 
        TAILQ_FOREACH(driver, &drivers_list, next) {
                if ((driver->drv_class & user_classes) == 0)
@@ -666,8 +666,10 @@ drivers_probe(struct mlx5_common_device *cdev, uint32_t user_classes)
                }
                enabled_classes |= driver->drv_class;
        }
-       cdev->classes_loaded |= enabled_classes;
-       return 0;
+       if (!ret) {
+               cdev->classes_loaded |= enabled_classes;
+               return 0;
+       }
 probe_err:
        /*
         * Need to remove only drivers which were not probed before this probe