All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev
@ 2011-08-08  9:14 Axel Lin
  2011-08-08  9:16 ` [PATCH 2/3] platform-drivers-x86: asus-wmi: fix resource leak in asus_wmi_led_exit Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Axel Lin @ 2011-08-08  9:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Corentin Chary, Matthew Garrett, acpi4asus-user,
	platform-driver-x86

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-08 12:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-08  9:14 [PATCH 1/3] platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev Axel Lin
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:18     ` Corentin Chary
2011-08-08 12:17 ` [PATCH 1/3] platform-drivers-x86: eeepc-laptop: " Corentin Chary

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.