* blktrace: Fix memleak problem in get_online_cpus()
@ 2021-06-29 2:29 lijinlin
2021-06-29 3:20 ` lijinlin
0 siblings, 1 reply; 2+ messages in thread
From: lijinlin @ 2021-06-29 2:29 UTC (permalink / raw)
To: linux-btrace
From: lijinlin <lijinlin3@huawei.com>
In get_online_cpus(), after cpu_nums is alloced memory successfully,
there are two return paths which don't free(cpunums).
Signed-off-by: lijinlin <lijinlin3@huawei.com>
---
blktrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/blktrace.c b/blktrace.c
index 3444fbb..f1f646a 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2759,6 +2759,7 @@ static cpu_set_t *get_online_cpus(void)
while (prevcpuid <= cpuid) {
/* More CPUs listed than configured? */
if (curcpu >= ncpu) {
+ free(cpu_nums);
errno = EINVAL;
return NULL;
}
@@ -2774,6 +2775,7 @@ static cpu_set_t *get_online_cpus(void)
/* Now that we have maximum cpu number, create a cpuset */
set = CPU_ALLOC(max_cpus);
if (!set) {
+ free(cpu_nums);
errno = ENOMEM;
return NULL;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* blktrace: Fix memleak problem in get_online_cpus()
2021-06-29 2:29 blktrace: Fix memleak problem in get_online_cpus() lijinlin
@ 2021-06-29 3:20 ` lijinlin
0 siblings, 0 replies; 2+ messages in thread
From: lijinlin @ 2021-06-29 3:20 UTC (permalink / raw)
To: linux-btrace
From: lijinlin <lijinlin3@huawei.com>
In get_online_cpus(), after cpu_nums is alloced memory successfully,
there are two return paths which don't free(cpu_nums).
Signed-off-by: lijinlin <lijinlin3@huawei.com>
---
blktrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/blktrace.c b/blktrace.c
index 3444fbb..f1f646a 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2759,6 +2759,7 @@ static cpu_set_t *get_online_cpus(void)
while (prevcpuid <= cpuid) {
/* More CPUs listed than configured? */
if (curcpu >= ncpu) {
+ free(cpu_nums);
errno = EINVAL;
return NULL;
}
@@ -2774,6 +2775,7 @@ static cpu_set_t *get_online_cpus(void)
/* Now that we have maximum cpu number, create a cpuset */
set = CPU_ALLOC(max_cpus);
if (!set) {
+ free(cpu_nums);
errno = ENOMEM;
return NULL;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-29 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 2:29 blktrace: Fix memleak problem in get_online_cpus() lijinlin
2021-06-29 3:20 ` lijinlin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).