7 Star 0 Fork 18

src-openEuler/blktrace

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0005-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
foolstrong 提交于 2024-07-31 11:33 . backport bugfix patches from upstream
From 7f5d2c5173d72018aa29c583c9291ef10abaf8df Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Thu, 21 Oct 2021 10:16:20 -0400
Subject: [PATCH 3/5] blkparse: fix incorrectly sized memset in check_cpu_map
The memset call in check_cpu_map always clears sizeof(unsigned long *)
regardless of what size was allocated. Use calloc instead to allocate
the map so it's zeroed properly regardless of the size requested.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blkparse.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 498857c..9d2029a 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2236,8 +2236,7 @@ static int check_cpu_map(struct per_dev_info *pdi)
/*
* create a map of the cpus we have traces for
*/
- cpu_map = malloc(pdi->cpu_map_max / sizeof(long));
- memset(cpu_map, 0, sizeof(*cpu_map));
+ cpu_map = calloc(1, pdi->cpu_map_max / sizeof(long));
n = rb_first(&rb_sort_root);
while (n) {
__t = rb_entry(n, struct trace, rb_node);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/blktrace.git
git@gitee.com:src-openeuler/blktrace.git
src-openeuler
blktrace
blktrace
master

搜索帮助