cpuidle-haltpoll: return -ENODEV on modinit failure
authorJoao Martins <joao.m.martins@oracle.com>
Sat, 7 Sep 2019 23:45:23 +0000 (00:45 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 11 Sep 2019 15:36:30 +0000 (17:36 +0200)
When a user loads cpuidle-haltpoll on a non KVM guest the module will
successfully load, even though idle driver registration didn't take
place.

We should instead return -ENODEV signaling the user that the driver can't
be loaded, like other error paths in haltpoll_init().  An example of such
error paths is when we return -EBUSY when attempting to register an idle
driver when it had one already (e.g. intel_idle loads at boot and then we
attempt to insert module cpuidle-haltpoll).

Fixes: fa86ee90eb11 ("add cpuidle-haltpoll driver")
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpuidle/cpuidle-haltpoll.c

index 519e90d125cfc6803ea74dedd11e7f869c16ca9f..7a0239ef717e9b497ba9ad3d4c94399da7c1215c 100644 (file)
@@ -99,7 +99,7 @@ static int __init haltpoll_init(void)
        cpuidle_poll_state_init(drv);
 
        if (!kvm_para_available())
-               return 0;
+               return -ENODEV;
 
        ret = cpuidle_register_driver(drv);
        if (ret < 0)