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-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 25 Dec 2023 18:34:29 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-edac@...r.kernel.org, kernel-janitors@...r.kernel.org,
 Borislav Petkov <bp@...en8.de>, James Morse <james.morse@....com>,
 Mauro Carvalho Chehab <mchehab@...nel.org>, Robert Richter
 <rric@...nel.org>, Tony Luck <tony.luck@...el.com>,
 Yazen Ghannam <yazen.ghannam@....com>
Cc: LKML <linux-kernel@...r.kernel.org>, cocci@...ia.fr,
 Muralidhara M K <muralidhara.mk@....com>
Subject: [PATCH 1/7] EDAC/amd64: Improve error handling in amd64_edac_init()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 25 Dec 2023 16:21:34 +0100

The kfree() function was called in one case by the
amd64_edac_init() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

1. Return directly after a call of the function “kcalloc” failed.

2. Move an error code assignment into an if branch.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/edac/amd64_edac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 537b9987a431..f912cbadefa4 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -4414,14 +4414,15 @@ static int __init amd64_edac_init(void)

 	opstate_init();

-	err = -ENOMEM;
 	ecc_stngs = kcalloc(amd_nb_num(), sizeof(ecc_stngs[0]), GFP_KERNEL);
 	if (!ecc_stngs)
-		goto err_free;
+		return -ENOMEM;

 	msrs = msrs_alloc();
-	if (!msrs)
+	if (!msrs) {
+		err = -ENOMEM;
 		goto err_free;
+	}

 	for (i = 0; i < amd_nb_num(); i++) {
 		err = probe_one_instance(i);
--
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ