diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-07 13:32:07 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 19:08:57 -0500 |
commit | fa4cd451cceb77e97432b91fcf50a7e4a7361e29 (patch) | |
tree | 5e5740ea38ebe390cc4f054e9fd5426003dcf46c | |
parent | 3eef34ad7dc369b7183ec383908aff3da2f6e5ec (diff) |
sysfs, kobject: add sysfs wrapper for kernfs_enable_ns()
Currently, kobject is invoking kernfs_enable_ns() directly. This is
fine now as sysfs and kernfs are enabled and disabled together. If
sysfs is disabled, kernfs_enable_ns() is switched to dummy
implementation too and everything is fine; however, kernfs will soon
have its own config option CONFIG_KERNFS and !SYSFS && KERNFS will be
possible, which can make kobject call into non-dummy
kernfs_enable_ns() with NULL kernfs_node pointers leading to an oops.
Introduce sysfs_enable_ns() which is a wrapper around
kernfs_enable_ns() so that it can be made a noop depending only on
CONFIG_SYSFS regardless of the planned CONFIG_KERNFS.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | include/linux/sysfs.h | 9 | ||||
-rw-r--r-- | lib/kobject.c | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 14df05415af9..fdaa0c6fc7a2 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
@@ -244,6 +244,11 @@ void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); | |||
244 | 244 | ||
245 | int __must_check sysfs_init(void); | 245 | int __must_check sysfs_init(void); |
246 | 246 | ||
247 | static inline void sysfs_enable_ns(struct kernfs_node *kn) | ||
248 | { | ||
249 | return kernfs_enable_ns(kn); | ||
250 | } | ||
251 | |||
247 | #else /* CONFIG_SYSFS */ | 252 | #else /* CONFIG_SYSFS */ |
248 | 253 | ||
249 | static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) | 254 | static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) |
@@ -416,6 +421,10 @@ static inline int __must_check sysfs_init(void) | |||
416 | return 0; | 421 | return 0; |
417 | } | 422 | } |
418 | 423 | ||
424 | static inline void sysfs_enable_ns(struct kernfs_node *kn) | ||
425 | { | ||
426 | } | ||
427 | |||
419 | #endif /* CONFIG_SYSFS */ | 428 | #endif /* CONFIG_SYSFS */ |
420 | 429 | ||
421 | static inline int __must_check sysfs_create_file(struct kobject *kobj, | 430 | static inline int __must_check sysfs_create_file(struct kobject *kobj, |
diff --git a/lib/kobject.c b/lib/kobject.c index cb14aeac4cca..58751bb80a7c 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -94,7 +94,7 @@ static int create_dir(struct kobject *kobj) | |||
94 | BUG_ON(ops->type >= KOBJ_NS_TYPES); | 94 | BUG_ON(ops->type >= KOBJ_NS_TYPES); |
95 | BUG_ON(!kobj_ns_type_registered(ops->type)); | 95 | BUG_ON(!kobj_ns_type_registered(ops->type)); |
96 | 96 | ||
97 | kernfs_enable_ns(kobj->sd); | 97 | sysfs_enable_ns(kobj->sd); |
98 | } | 98 | } |
99 | 99 | ||
100 | return 0; | 100 | return 0; |