The issues mainly lies in the memory empty check, variable range inconsistency, parameter verification, and print format. Signed-off-by: Luoyouming <luoyouming@huawei.com> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com Signed-off-by: Ran Zhou <zhouran10@h-partners.com> (cherry picked from commit 918525387673e173835fd287995470cbaccad784)
46 lines
1.4 KiB
Diff
46 lines
1.4 KiB
Diff
From 884663cd803e3781aec9c45f7fc0145b6a2b4539 Mon Sep 17 00:00:00 2001
|
|
From: Luoyouming <luoyouming@huawei.com>
|
|
Date: Mon, 27 Nov 2023 16:39:49 +0800
|
|
Subject: [PATCH 72/75] libhns: Add input parameter check for
|
|
hnsdv_query_device()
|
|
|
|
driver inclusion
|
|
category: cleanup
|
|
bugzilla: https://gitee.com/src-openeuler/rdma-core/issues/I8J2W9?from=project-issue
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
Add null pointer check for pointer parameter.
|
|
|
|
Signed-off-by: Luoyouming <luoyouming@huawei.com>
|
|
---
|
|
providers/hns/hns_roce_u_verbs.c | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/providers/hns/hns_roce_u_verbs.c b/providers/hns/hns_roce_u_verbs.c
|
|
index c906632..e597e93 100644
|
|
--- a/providers/hns/hns_roce_u_verbs.c
|
|
+++ b/providers/hns/hns_roce_u_verbs.c
|
|
@@ -126,15 +126,16 @@ int hnsdv_query_device(struct ibv_context *context,
|
|
struct hnsdv_context *attrs_out)
|
|
{
|
|
struct hns_roce_context *ctx = context ? to_hr_ctx(context) : NULL;
|
|
- struct hns_roce_device *hr_dev = to_hr_dev(context->device);
|
|
+ struct hns_roce_device *hr_dev;
|
|
|
|
if (!ctx || !attrs_out)
|
|
return EINVAL;
|
|
|
|
- if (!hr_dev) {
|
|
+ if (!context->device && !is_hns_dev(context->device)) {
|
|
verbs_err(verbs_get_ctx(context), "not a HNS RoCE device!\n");
|
|
return EOPNOTSUPP;
|
|
}
|
|
+ hr_dev = to_hr_dev(context->device);
|
|
|
|
memset(attrs_out, 0, sizeof(*attrs_out));
|
|
|
|
--
|
|
2.25.1
|
|
|