加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-double-free-in-tpm.patch 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
From b313cae9712a5c13ad9617c39019693072372499 Mon Sep 17 00:00:00 2001
From: jinlun <jinlun@huawei.com>
Date: Mon, 17 Jun 2024 14:58:16 +0800
Subject: [PATCH 03/14] fix double free in tpm
---
src/common/dim_tpm.c | 4 +++-
src/measure/dim_measure.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/common/dim_tpm.c b/src/common/dim_tpm.c
index 6d3c255..35f3fac 100644
--- a/src/common/dim_tpm.c
+++ b/src/common/dim_tpm.c
@@ -74,4 +74,6 @@ void dim_tpm_destroy(struct dim_tpm *tpm)
put_device(&tpm->chip->dev);
dim_kfree(tpm->digests);
-}
\ No newline at end of file
+ tpm->chip = NULL;
+ tpm->digests = NULL;
+}
diff --git a/src/measure/dim_measure.c b/src/measure/dim_measure.c
index dd35cb8..c40be0e 100644
--- a/src/measure/dim_measure.c
+++ b/src/measure/dim_measure.c
@@ -44,8 +44,10 @@ int dim_measure_init(struct dim_measure *m, struct dim_measure_cfg *cfg)
/* 2. init TPM, dont break if init fail */
if (cfg->pcr > 0) {
ret = dim_tpm_init(&m->tpm, HASH_ALGO_SHA256);
- if (ret < 0)
+ if (ret < 0) {
+ cfg->pcr = 0;
dim_warn("failed to init tpm chip: %d\n", ret);
+ }
} else {
memset(&m->tpm, 0, sizeof(struct dim_tpm));
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化