X86 platform drivers
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
To: alan-jenkins@tuffmail.co.uk
Cc: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	platform-driver-x86@vger.kernel.org, mjg@redhat.com,
	don@syst.com.br, rpurdie@rpsys.net
Subject: [PATCH] classmate-laptop: should check for NULL as retval for rfkill_alloc
Date: Wed,  9 Jun 2010 16:39:28 -0300	[thread overview]
Message-ID: <1276112368-3057-1-git-send-email-cascardo@holoscopio.com> (raw)
In-Reply-To: <20100609185803.GB2551@barata.holoscopio.com>

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@tuffmail.co.uk>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: platform-driver-x86@vger.kernel.org
Cc: mjg@redhat.com
Cc: don@syst.com.br
Cc: rpurdie@rpsys.net
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
---
 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


  reply	other threads:[~2010-06-09 19:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 16:15 [PATCH] classmate-laptop: Add RFKILL support Thadeu Lima de Souza Cascardo
2010-04-27 16:22 ` Matthew Garrett
2010-04-27 16:32   ` Thadeu Lima de Souza Cascardo
2010-05-07 18:18     ` Matthew Garrett
2010-06-09 10:28 ` Alan Jenkins
2010-06-09 18:19   ` Thadeu Lima de Souza Cascardo
2010-06-09 18:32     ` Johannes Berg
2010-06-09 18:58       ` Thadeu Lima de Souza Cascardo
2010-06-09 19:39         ` Thadeu Lima de Souza Cascardo [this message]
2010-06-09 19:46           ` [PATCH] classmate-laptop: should check for NULL as retval for rfkill_alloc Johannes Berg
2010-06-09 19:48             ` Thadeu Lima de Souza Cascardo
2010-06-09 19:49             ` Thadeu Lima de Souza Cascardo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1276112368-3057-1-git-send-email-cascardo@holoscopio.com \
    --to=cascardo@holoscopio.com \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=don@syst.com.br \
    --cc=johannes@sipsolutions.net \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox