1 Star 0 Fork 121

侯景博/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
block-virtio-blk-Fix-memory-leak-from-virtio_blk_zon.patch 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-04-22 10:20 . QEMU update to version 8.2.0-10
From b54d853396820150735294107e2e3d060724de04 Mon Sep 17 00:00:00 2001
From: qihao <[email protected]>
Date: Mon, 8 Apr 2024 14:39:43 +0800
Subject: [PATCH] block/virtio-blk: Fix memory leak from virtio_blk_zone_report
cheery-pick from bbdf9023665f409113cb07b463732861af63fb47
This modification ensures that in scenarios where the buffer size is
insufficient for a zone report, the function will now properly set an
error status and proceed to a cleanup label, instead of merely
returning.
The following ASAN log reveals it:
==1767400==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 312 byte(s) in 1 object(s) allocated from:
#0 0x64ac7b3280cd in malloc llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:129:3
#1 0x735b02fb9738 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5e738)
#2 0x64ac7d23be96 in virtqueue_split_pop hw/virtio/virtio.c:1612:12
#3 0x64ac7d23728a in virtqueue_pop hw/virtio/virtio.c:1783:16
#4 0x64ac7cfcaacd in virtio_blk_get_request hw/block/virtio-blk.c:228:27
#5 0x64ac7cfca7c7 in virtio_blk_handle_vq hw/block/virtio-blk.c:1123:23
#6 0x64ac7cfecb95 in virtio_blk_handle_output hw/block/virtio-blk.c:1157:5
Signed-off-by: Zheyu Ma <[email protected]>
Message-id: [email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: qihao_yewu <[email protected]>
---
hw/block/virtio-blk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 1ebc9188c0..2eb096a6dc 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -790,7 +790,8 @@ static void virtio_blk_handle_zone_report(VirtIOBlockReq *req,
sizeof(struct virtio_blk_zone_report) +
sizeof(struct virtio_blk_zone_descriptor)) {
virtio_error(vdev, "in buffer too small for zone report");
- return;
+ err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
+ goto out;
}
/* start byte offset of the zone report */
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Destiny_zhuohua/qemu.git
[email protected]:Destiny_zhuohua/qemu.git
Destiny_zhuohua
qemu
qemu
master

搜索帮助