From: Luoyouming luoyouming@huawei.com
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.30.0