lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220615073348.6891-1-jianchunfu@cmss.chinamobile.com>
Date:   Wed, 15 Jun 2022 15:33:48 +0800
From:   jianchunfu <jianchunfu@...s.chinamobile.com>
To:     bristot@...nel.org, rostedt@...dmis.org
Cc:     linux-trace-devel@...r.kernel.org, linux-kernel@...r.kernel.org,
        jianchunfu <jianchunfu@...s.chinamobile.com>
Subject: [PATCH v2] rtla/utils: Use calloc and check the potential memory allocation failure

Replace malloc with calloc and add memory allocating check
of mon_cpus before used.

Fixes: 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
Signed-off-by: jianchunfu <jianchunfu@...s.chinamobile.com>
---
V1 -> V2: using calloc, removing the memset and goto err
	  instead of returning when allocation fails.
---
 tools/tracing/rtla/src/utils.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c
index ffaf8ec84..56bdc9962 100644
--- a/tools/tracing/rtla/src/utils.c
+++ b/tools/tracing/rtla/src/utils.c
@@ -105,8 +105,9 @@ int parse_cpu_list(char *cpu_list, char **monitored_cpus)
 
 	nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
 
-	mon_cpus = malloc(nr_cpus * sizeof(char));
-	memset(mon_cpus, 0, (nr_cpus * sizeof(char)));
+	mon_cpus = calloc(nr_cpus, sizeof(char));
+	if (!mon_cpus)
+		goto err;
 
 	for (p = cpu_list; *p; ) {
 		cpu = atoi(p);
-- 
2.18.4



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ