Skip to contentSkip to conversation

common/mlx5: fix probing return value when failing

PATCH In review Bing Zhao 2 participants 2 messages Jan 17, 2022 – Jan 26, 2022

lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH 1/1 common/mlx5: fix probing return value when failing

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")
---
 drivers/common/mlx5/mlx5_common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/common/mlx5/mlx5_common.c +5 -3
index 185db4d004..47a541f5ef 100644
@@ -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
Signature · 1 line
2.27.0
#1 lore raw

Hi,

Quoted 16 lines

-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Monday, January 17, 2022 7:49 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; Xueming(Steven) Li <[email protected]>; [email protected]
Subject: [PATCH] common/mlx5: fix probing return value when failing

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.

Quoted 6 lines
Fixes ad435d320473 ("common/mlx5: add bus-agnostic layer")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh