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>] [day] [month] [year] [list]
Message-Id: <20221019014614.3120-1-kunyu@nfschina.com>
Date:   Wed, 19 Oct 2022 09:46:14 +0800
From:   Li kunyu <kunyu@...china.com>
To:     shuah@...nel.org, trenn@...e.com
Cc:     ray.huang@....com, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Li kunyu <kunyu@...china.com>
Subject: [v2 PATCH] power: cpupower: utils: Add malloc return value check

Add the check and judgment statement of malloc return value.

Signed-off-by: Li kunyu <kunyu@...china.com>
---
 v2: Remove unlikely() check

 tools/power/cpupower/utils/helpers/misc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
index 36dbd0562240..083d5a6bb74e 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -139,6 +139,8 @@ void print_online_cpus(void)
 
 	str_len = online_cpus->size * 5;
 	online_cpus_str = malloc(sizeof(char) * str_len);
+	if (!online_cpus_str)
+		return;
 
 	if (!bitmask_isallclear(online_cpus)) {
 		bitmask_displaylist(online_cpus_str, str_len, online_cpus);
@@ -157,6 +159,8 @@ void print_offline_cpus(void)
 
 	str_len = offline_cpus->size * 5;
 	offline_cpus_str = malloc(sizeof(char) * str_len);
+	if (!offline_cpus_str)
+		return;
 
 	if (!bitmask_isallclear(offline_cpus)) {
 		bitmask_displaylist(offline_cpus_str, str_len, offline_cpus);
-- 
2.18.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ