From: Bing Zhao <bingz@nvidia.com>
To: <viacheslavo@nvidia.com>, <matan@nvidia.com>
Cc: <dev@dpdk.org>, <rasland@nvidia.com>, <xuemingl@nvidia.com>,
<stable@dpdk.org>
Subject: [PATCH] common/mlx5: fix probing return value when failing
Date: Mon, 17 Jan 2022 19:49:14 +0200 [thread overview]
Message-ID: <20220117174914.82613-1-bingz@nvidia.com> (raw)
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: xuemingl@nvidia.com
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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 185db4d004..47a541f5ef 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -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
--
2.27.0
next reply other threads:[~2022-01-17 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 17:49 Bing Zhao [this message]
2022-01-26 15:27 ` Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220117174914.82613-1-bingz@nvidia.com \
--to=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--cc=viacheslavo@nvidia.com \
--cc=xuemingl@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).