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]
Message-ID: <51DE2F55.2070109@asianux.com>
Date:	Thu, 11 Jul 2013 12:06:45 +0800
From:	Chen Gang <gang.chen@...anux.com>
To:	Rusty Russell <rusty@...tcorp.com.au>
CC:	khali@...ux-fr.org, David.Woodhouse@...el.com,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] kernel/params.c: add/modify failure processing code when
 sysfs_create_file() fails.

When sysfs_create_file() fails, need consider about it. And process it
with BUG_ON(), because sysfs_create_file() can fail due to OOM (not at
boot) or name duplication (not here).

Also correct the error printing information when failure occurs.

Signed-off-by: Chen Gang <gang.chen@...anux.com>
---
 kernel/params.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/params.c b/kernel/params.c
index 440e65d..3d70f90 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -745,12 +745,14 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
 		err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL,
 					   "%s", name);
 #ifdef CONFIG_MODULES
-		if (!err)
+		if (!err) {
 			err = sysfs_create_file(&mk->kobj, &module_uevent.attr);
+			BUG_ON(err);
+		}
 #endif
 		if (err) {
 			kobject_put(&mk->kobj);
-			pr_crit("Adding module '%s' to sysfs failed (%d), the system may be unstable.\n",
+			pr_crit("Initializing and adding module '%s' failed (%d), the system may be unstable.\n",
 				name, err);
 			return NULL;
 		}
@@ -845,6 +847,7 @@ static void __init version_sysfs_builtin(void)
 		mk = locate_module_kobject(vattr->module_name);
 		if (mk) {
 			err = sysfs_create_file(&mk->kobj, &vattr->mattr.attr);
+			BUG_ON(err);
 			kobject_uevent(&mk->kobj, KOBJ_ADD);
 			kobject_put(&mk->kobj);
 		}
-- 
1.7.7.6
--
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