From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Corentin Chary <corentincj@iksaif.net>,
Matthew Garrett <mjg@redhat.com>,
acpi4asus-user@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org
Subject: [PATCH 1/3] platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev
Date: Mon, 08 Aug 2011 17:14:19 +0800 [thread overview]
Message-ID: <1312794859.21052.2.camel@phoenix> (raw)
device_create returns &struct device pointer on success, or ERR_PTR() on error.
Thus if led_classdev_register fails, led_cdev->dev is always not NULL.
If IS_ERR(eeepc->tpd_led.dev) is ture, it means led_classdev_register fails.
If (asus->tpd_led.dev) is NULL, it means we call eeepc_led_exit before
calling led_classdev_register for &eeepc->tpd_led.
We only want to call led_classdev_unregister for sucessfully registered
led_classdev, then we should check (!IS_ERR_OR_NULL(eeepc->tpd_led.dev)).
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/platform/x86/eeepc-laptop.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 1c45d92..29a216a 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -568,7 +568,7 @@ static int eeepc_led_init(struct eeepc_laptop *eeepc)
static void eeepc_led_exit(struct eeepc_laptop *eeepc)
{
- if (eeepc->tpd_led.dev)
+ if (!IS_ERR_OR_NULL(eeepc->tpd_led.dev))
led_classdev_unregister(&eeepc->tpd_led);
if (eeepc->led_workqueue)
destroy_workqueue(eeepc->led_workqueue);
--
1.7.4.1
next reply other threads:[~2011-08-08 9:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-08 9:14 Axel Lin [this message]
2011-08-08 9:16 ` [PATCH 2/3] platform-drivers-x86: asus-wmi: fix resource leak in asus_wmi_led_exit Axel Lin
2011-08-08 12:18 ` Corentin Chary
2011-08-08 9:17 ` [PATCH 3/3] platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev Axel Lin
2011-08-08 12:18 ` Corentin Chary
2011-08-08 12:17 ` [PATCH 1/3] platform-drivers-x86: eeepc-laptop: " Corentin Chary
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=1312794859.21052.2.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=corentincj@iksaif.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
/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