diff options
author | Gaurav Minocha <gaurav.minocha.os@gmail.com> | 2014-09-05 09:56:13 -0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-02-20 23:41:18 +0900 |
commit | ed22824fc77e158ae6075b06c3047a12731553c3 (patch) | |
tree | 128b334b0aa4bb91d3650adfdbd078d44c7690f6 | |
parent | 220f5ea9df1e8ded213958f635b5310de44305d2 (diff) |
of: Disabling OF functions that use sysfs if CONFIG_SYSFS disabled
This patch is to the fix the recent runtime bug in kernel reported by
<fengguang.wu@intel.com>. The bug was exposed by commit b951f9dc,
"Enabling OF selftest to run without machine's devicetree" and is
exposed when CONFIG_OF_SELFTEST is enabled and CONFIG_SYSFS is
disabled.
Mail Subject: [OF test] BUG: unable to handle kernel NULL pointer
dereference at 00000038
Tested on x86 and arm architecture
Signed-off-by: Gaurav Minocha <gaurav.minocha.os@gmail.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
(cherry picked from commit ef69d74035befbddd7c2b7e86120e49191107acc)
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/of/base.c | 12 | ||||
-rw-r--r-- | drivers/of/dynamic.c | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 8059f149d171..a810ab79c6f4 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -136,6 +136,9 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp) /* Important: Don't leak passwords */ bool secure = strncmp(pp->name, "security-", 9) == 0; + if (!IS_ENABLED(CONFIG_SYSFS)) + return 0; + if (!of_kset || !of_node_is_attached(np)) return 0; @@ -156,6 +159,9 @@ int __of_attach_node_sysfs(struct device_node *np) struct property *pp; int rc; + if (!IS_ENABLED(CONFIG_SYSFS)) + return 0; + if (!of_kset) return 0; @@ -1637,6 +1643,9 @@ int __of_remove_property(struct device_node *np, struct property *prop) void __of_remove_property_sysfs(struct device_node *np, struct property *prop) { + if (!IS_ENABLED(CONFIG_SYSFS)) + return; + /* at early boot, bail here and defer setup to of_init() */ if (of_kset && of_node_is_attached(np)) sysfs_remove_bin_file(&np->kobj, &prop->attr); @@ -1701,6 +1710,9 @@ int __of_update_property(struct device_node *np, struct property *newprop, void __of_update_property_sysfs(struct device_node *np, struct property *newprop, struct property *oldprop) { + if (!IS_ENABLED(CONFIG_SYSFS)) + return; + /* At early boot, bail out and defer setup to of_init() */ if (!of_kset) return; diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 54fecc49a1fe..f297891d8529 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -45,6 +45,9 @@ void __of_detach_node_sysfs(struct device_node *np) { struct property *pp; + if (!IS_ENABLED(CONFIG_SYSFS)) + return; + BUG_ON(!of_node_is_initialized(np)); if (!of_kset) return; |