aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-03-24 00:43:46 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-03-24 00:43:46 +0100
commit90ff2b729e181fba628b854eac2097e5ccc22e66 (patch)
tree3f01f4309a411eaa1cb7a8889bc5706a8e7d0ceb /drivers
parent6488294e4a6328ca260b9d872c04cbd7db09e17e (diff)
parentad0a45fd9c14feebd000b6e84189d0edff265170 (diff)
Merge branch 'pm-cpuidle-fixes'
* pm-cpuidle-fixes: cpuidle: Validate cpu_dev in cpuidle_add_sysfs()
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpuidle/sysfs.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index c5adc8c9ac43..ae948b1da93a 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -615,6 +615,18 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
int error;
+ /*
+ * Return if cpu_device is not setup for this CPU.
+ *
+ * This could happen if the arch did not set up cpu_device
+ * since this CPU is not in cpu_present mask and the
+ * driver did not send a correct CPU mask during registration.
+ * Without this check we would end up passing bogus
+ * value for &cpu_dev->kobj in kobject_init_and_add()
+ */
+ if (!cpu_dev)
+ return -ENODEV;
+
kdev = kzalloc(sizeof(*kdev), GFP_KERNEL);
if (!kdev)
return -ENOMEM;