summaryrefslogtreecommitdiff
path: root/drivers/cpuidle/sysfs.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-03-28 10:34:19 +0300
committerDave Airlie <airlied@redhat.com>2017-03-28 10:34:19 +0300
commite5c1ff14757afe21733ddee9cc4bbaeaeadbf803 (patch)
tree0da1c9aaf772fac30fe68590a4ca1c3dd439cebd /drivers/cpuidle/sysfs.c
parent65d1086c44791112188f6aebbdc3a27cab3736d3 (diff)
parentc02ed2e75ef4c74e41e421acb4ef1494671585e8 (diff)
downloadlinux-e5c1ff14757afe21733ddee9cc4bbaeaeadbf803.tar.xz
Backmerge tag 'v4.11-rc4' into drm-next
Linux 4.11-rc4 The i915 GVT team need the rc4 code to base some more code on.
Diffstat (limited to 'drivers/cpuidle/sysfs.c')
-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;