From 485cddd47c83d6f229450b28d55d8e07f60ddcc0 Mon Sep 17 00:00:00 2001
From: Yuyu Li <liyuyu6@huawei.com>
Date: Thu, 21 Nov 2024 21:37:15 +0800
Subject: [PATCH] libhns: Fix bypassed vendor check in hnsdv_query_device()

driver inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/IBF87T

--------------------------------------------------------------------------

The device vendor check is actually bypassed currently due
to the wrong if-condition. It should be a '||' statement.

Fixes: 19e1eabc154f ("libhns: Add input parameter check for hnsdv_query_device()")
Signed-off-by: Yuyu Li <liyuyu6@huawei.com>
---
 providers/hns/hns_roce_u_verbs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
index 090efbf..a6afce2 100644
--- a/providers/hns/hns_roce_u_verbs.c
+++ b/providers/hns/hns_roce_u_verbs.c
@@ -128,10 +128,10 @@ int hnsdv_query_device(struct ibv_context *context,
 	struct hns_roce_context *ctx = context ? to_hr_ctx(context) : NULL;
 	struct hns_roce_device *hr_dev;
 
-	if (!ctx || !attrs_out)
+	if (!ctx || !context->device || !attrs_out)
 		return EINVAL;
 
-	if (!context->device && !is_hns_dev(context->device)) {
+	if (!is_hns_dev(context->device)) {
 		verbs_err(verbs_get_ctx(context), "not a HNS RoCE device!\n");
 		return EOPNOTSUPP;
 	}
-- 
2.33.0

