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:	Wed, 18 Nov 2015 17:48:31 +0100
From:	Nicolai Stange <nicstange@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:	Nicolai Stange <nicstange@...il.com>,
	Theodore Ts'o <tytso@....edu>,
	Andreas Dilger <adilger.kernel@...ger.ca>,
	Mark Fasheh <mfasheh@...e.com>,
	Joel Becker <jlbec@...lplan.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Joe Perches <joe@...ches.com>, linux-kernel@...r.kernel.org,
	linux-ext4@...r.kernel.org, ocfs2-devel@....oracle.com
Subject: [PATCH v2 2/3] drivers/base/class: __class_register(): make error behaviour consistent

If a class attribute's sysfs creation fails at the very end of
__class_register(), the kset object already registered for the class itself
is not unregistered again.

This is not consistent with the other possible failures of
__class_register() for which nothing is left over to be manually released
by the caller.

Since class attribute creation does not fail in the real world, the
impact is minimal -- this patch is a cosmetic one.

Make __class_register() follow all-or-nothing semantics, i.e. unregister
the already registered cp->subsys kset object on attribute creation
failure.

Signed-off-by: Nicolai Stange <nicstange@...il.com>
---
 drivers/base/class.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index c9683cf..fc663d0 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -225,6 +225,12 @@ int __class_register(struct class *cls, struct lock_class_key *key)
 	}
 	error = add_class_attrs(class_get(cls));
 	class_put(cls);
+	if (error) {
+		/* as above, clear cp->class on error */
+		cp->class = NULL;
+		cls->p = NULL;
+		kset_put(&cp->subsys);
+	}
 	return error;
 }
 EXPORT_SYMBOL_GPL(__class_register);
-- 
2.6.3

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ