blktrace: Fix memleak problem in get_online_cpus()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: lijinlin <lijinlin3@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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



[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux