代码拉取完成,页面将自动刷新
From 2abbc6020498b1c464775623de8b2db76e684d55 Mon Sep 17 00:00:00 2001
From: Junxian Huang <huangjunxian6@hisilicon.com>
Date: Tue, 24 Oct 2023 11:16:49 +0800
Subject: hikptool/roce: Use calloc to alloc memory for array instead of malloc
calloc is more situable for memory allocation for array than malloc,
since the allocated memory will be set to 0.
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 d0fae69..d5ae64a 100644
--- a/net/roce/roce_ext_common/hikp_roce_ext_common.c
+++ b/net/roce/roce_ext_common/hikp_roce_ext_common.c
@@ -115,8 +115,8 @@ static int hikp_roce_ext_get_res(enum roce_cmd_type cmd_type,
max_size = res_head->total_block_num * sizeof(uint32_t);
if (block_id == 0) {
- reg->offset = (uint32_t *)malloc(max_size);
- reg->data = (uint32_t *)malloc(max_size);
+ 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)) {
printf("hikptool roce_%s alloc log memmory 0x%x failed!\n",
cmd_name, max_size);
--
2.30.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。