Synchronize code, Modify the review comments to increase the reliability of the code Signed-off-by: veega2022 <zhuweijia@huawei.com> (cherry picked from commit d2a23f9ffed0201385c7864b9cd58312fb395cb6)
37 lines
1.6 KiB
Diff
37 lines
1.6 KiB
Diff
From 53a9e2244b16196681e96a1cbaf9e23eef22f56d Mon Sep 17 00:00:00 2001
|
|
From: Junxian Huang <huangjunxian6@hisilicon.com>
|
|
Date: Mon, 5 Aug 2024 19:47:31 +0800
|
|
Subject: [PATCH 04/27] hikptool/roce: Fix redundant update of total_block_num
|
|
|
|
total_block_num needs to be updated only in the first loop of query,
|
|
and should stay constant from then on. Otherwise there may be
|
|
out-of-bound accessing problems if subsequent update value from FW
|
|
is larger than the first one, with which the memory of the register
|
|
array is allocated.
|
|
|
|
Fixes: 8b3b68347165 ("hikptool/roce: Add a common frame for hikptool roce register query")
|
|
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
|
|
---
|
|
net/roce/roce_ext_common/hikp_roce_ext_common.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/net/roce/roce_ext_common/hikp_roce_ext_common.c b/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
|
index e90720c..049b64a 100644
|
|
--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
|
+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c
|
|
@@ -118,9 +118,10 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type,
|
|
}
|
|
|
|
roce_ext_res = (struct roce_ext_res_param *)cmd_ret->rsp_data;
|
|
- *res_head = roce_ext_res->head;
|
|
+ res_head->cur_block_num = roce_ext_res->head.cur_block_num;
|
|
|
|
if (block_id == 0) {
|
|
+ res_head->total_block_num = roce_ext_res->head.total_block_num;
|
|
reg->offset = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t));
|
|
reg->data = (uint32_t *)calloc(res_head->total_block_num, sizeof(uint32_t));
|
|
if ((reg->offset == NULL) || (reg->data == NULL)) {
|
|
--
|
|
2.45.0.windows.1
|
|
|