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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1299494183-7380-1-git-send-email-johan.wessfeldt@gmail.com>
Date:	Mon,  7 Mar 2011 11:36:23 +0100
From:	Johan Wessfeldt <johan.wessfeldt@...il.com>
To:	unlisted-recipients:; (no To-header on input)
Cc:	x86@...nel.org, tglx@...utronix.de, linux-kernel@...r.kernel.org,
	Johan Wessfeldt <johan.wessfeldt@...il.com>
Subject: [PATCH V2] x86: mce: Potential memory leaks when initializing mcheck devices

This patch makes sure cleanup is done properly when mcheck fails
initializing any of its resources.

Signed-off-by: Johan Wessfeldt <johan.wessfeldt@...il.com>
---
v2: call free_cpumask_var() if sysdev_class_register() fails

 arch/x86/kernel/cpu/mcheck/mce.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d916183..3cbd5a0 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2131,20 +2131,32 @@ static __init int mcheck_init_device(void)
 
 	err = sysdev_class_register(&mce_sysclass);
 	if (err)
-		return err;
+		goto out_free;
 
 	for_each_online_cpu(i) {
 		err = mce_create_device(i);
 		if (err)
-			return err;
+			goto out_unreg;
 	}
 
 	register_hotcpu_notifier(&mce_cpu_notifier);
-	misc_register(&mce_log_device);
+	err = misc_register(&mce_log_device);
+	if (err)
+		goto out_unreg_hotcpu;
 
+	return 0;
+
+out_unreg_hotcpu:
+	unregister_hotcpu_notifier(&mce_cpu_notifier);
+out_unreg:
+	for_each_online_cpu(i)
+		mce_remove_device(i);
+
+	sysdev_class_unregister(&mce_sysclass);
+out_free:
+	free_cpumask_var(mce_dev_initialized);
 	return err;
 }
-
 device_initcall(mcheck_init_device);
 
 /*
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ