rfkill_alloc returns NULL when it fails if RFKILL is enabled. When RFKILL is disabled, its return value of ERR_PTR(-ENODEV) is OK to use as all rfkill functions will work with it, as they are simply empty stubs. Reported-by: Alan Jenkins <alan-jenkins@xxxxxxxxxxxxxx> Cc: Johannes Berg <johannes@xxxxxxxxxxxxxxxx> Cc: platform-driver-x86@xxxxxxxxxxxxxxx Cc: mjg@xxxxxxxxxx Cc: don@xxxxxxxxxxx Cc: rpurdie@xxxxxxxxx Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxxxxxx> --- drivers/platform/x86/classmate-laptop.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c index 3bf399f..a0aaf5b 100644 --- a/drivers/platform/x86/classmate-laptop.c +++ b/drivers/platform/x86/classmate-laptop.c @@ -573,9 +573,12 @@ static int cmpc_ipml_add(struct acpi_device *acpi) ipml->rf = rfkill_alloc("cmpc_rfkill", &acpi->dev, RFKILL_TYPE_WLAN, &cmpc_rfkill_ops, acpi->handle); - /* rfkill_alloc may fail if RFKILL is disabled. We should still work - * anyway. */ - if (!IS_ERR(ipml->rf)) { + /* + * If RFKILL is disabled, rfkill_alloc will return ERR_PTR(-ENODEV). + * This is OK, however, since all other uses of the device will not + * derefence it. + */ + if (!ipml->rf) { retval = rfkill_register(ipml->rf); if (retval) { rfkill_destroy(ipml->rf); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html