[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_074552B42B4D25D2329613D8@qq.com>
Date: Wed, 19 Feb 2014 15:06:15 +0800
From: "Yuan Pengfei" <coolypf@...com>
To: "Peter Oberparleiter"
<oberpar@...ux.vnet.ibm.com>
Cc: "linux-kernel" <linux-kernel@...r.kernel.org>
Subject: [PATCH] gcov: fix memory allocation problem in gcov_info_dup
From: Yuan Pengfei <coolypf@...com>
If -fprofile-values option is used, ctr->num and sci_ptr->num
may be zero, resulting in zero size and cv_size, which will
cause ENOMEM when opening gcov data files in debugfs.
Signed-off-by: Yuan Pengfei <coolypf@...com>
---
kernel/gcov/gcc_3_4.c | 2 +-
kernel/gcov/gcc_4_7.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/gcov/gcc_3_4.c b/kernel/gcov/gcc_3_4.c
index 27bc88a..1c1f425 100644
--- a/kernel/gcov/gcc_3_4.c
+++ b/kernel/gcov/gcc_3_4.c
@@ -269,7 +269,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
dup->counts[i].num = ctr->num;
dup->counts[i].merge = ctr->merge;
dup->counts[i].values = vmalloc(size);
- if (!dup->counts[i].values)
+ if (size && !dup->counts[i].values)
goto err_free;
memcpy(dup->counts[i].values, ctr->values, size);
}
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 2c6e463..7465944 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -290,7 +290,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
dci_ptr->values = vmalloc(cv_size);
- if (!dci_ptr->values)
+ if (cv_size && !dci_ptr->values)
goto err_free;
dci_ptr->num = sci_ptr->num;
--
1.8.5.3
Powered by blists - more mailing lists