* [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; 6+ 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] 6+ messages in thread
* [PATCH 2/3] platform-drivers-x86: asus-wmi: fix resource leak in asus_wmi_led_exit
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 ` 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:17 ` [PATCH 1/3] platform-drivers-x86: eeepc-laptop: " Corentin Chary
2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2011-08-08 9:16 UTC (permalink / raw)
To: linux-kernel
Cc: Corentin Chary, Matthew Garrett, acpi4asus-user, platform-driver-x86
This patch fixes wrong test for successful registered led_classdev,
and also fixes a leak due to missing led_classdev_unregister call
for asus->kbd_led in asus_wmi_led_exit.
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.
Thus to unregister a successful registered led_classdev, we should check
(!IS_ERR_OR_NULL(asus->tpd_led.dev)) instead of (asus->tpd_led.dev).
we use IS_ERR_OR_NULL instead of IS_ERR because if we havn't call
led_classdev_register, the led_cdev->dev is NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/platform/x86/asus-wmi.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 95cba9e..d1049ee 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -453,7 +453,9 @@ static enum led_brightness kbd_led_get(struct led_classdev *led_cdev)
static void asus_wmi_led_exit(struct asus_wmi *asus)
{
- if (asus->tpd_led.dev)
+ if (!IS_ERR_OR_NULL(asus->kbd_led.dev))
+ led_classdev_unregister(&asus->kbd_led);
+ if (!IS_ERR_OR_NULL(asus->tpd_led.dev))
led_classdev_unregister(&asus->tpd_led);
if (asus->led_workqueue)
destroy_workqueue(asus->led_workqueue);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev
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 9:17 ` Axel Lin
2011-08-08 12:18 ` Corentin Chary
2011-08-08 12:17 ` [PATCH 1/3] platform-drivers-x86: eeepc-laptop: " Corentin Chary
2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2011-08-08 9:17 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.
Thus to unregister a successful registered led_classdev, we should check
IS_ERR_OR_NULL macro for led_cdev->dev instead of checking if led_cdev->dev
is NULL or not.
we use IS_ERR_OR_NULL instead of IS_ERR because if we havn't call
led_classdev_register, the led_cdev->dev is NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/platform/x86/asus-laptop.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index fa6d7ec..0e071fa 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -430,17 +430,17 @@ static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev)
static void asus_led_exit(struct asus_laptop *asus)
{
- if (asus->mled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->mled.led.dev))
led_classdev_unregister(&asus->mled.led);
- if (asus->tled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->tled.led.dev))
led_classdev_unregister(&asus->tled.led);
- if (asus->pled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->pled.led.dev))
led_classdev_unregister(&asus->pled.led);
- if (asus->rled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->rled.led.dev))
led_classdev_unregister(&asus->rled.led);
- if (asus->gled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->gled.led.dev))
led_classdev_unregister(&asus->gled.led);
- if (asus->kled.led.dev)
+ if (!IS_ERR_OR_NULL(asus->kled.led.dev))
led_classdev_unregister(&asus->kled.led);
if (asus->led_workqueue) {
destroy_workqueue(asus->led_workqueue);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] platform-drivers-x86: eeepc-laptop: fix wrong test for successful registered led_classdev
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 9:17 ` [PATCH 3/3] platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev Axel Lin
@ 2011-08-08 12:17 ` Corentin Chary
2 siblings, 0 replies; 6+ messages in thread
From: Corentin Chary @ 2011-08-08 12:17 UTC (permalink / raw)
To: Axel Lin
Cc: linux-kernel, Matthew Garrett, acpi4asus-user, platform-driver-x86
Good catch ! It would be great to have a coccinel script to check that
in scripts/coccinelle/null/.
On Mon, Aug 8, 2011 at 11:14 AM, Axel Lin <axel.lin@gmail.com> wrote:
> 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>
Acked-by: Corentin Chary <corentin.chary@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
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Corentin Chary
http://xf.iksaif.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] platform-drivers-x86: asus-wmi: fix resource leak in asus_wmi_led_exit
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
0 siblings, 0 replies; 6+ messages in thread
From: Corentin Chary @ 2011-08-08 12:18 UTC (permalink / raw)
To: Axel Lin
Cc: linux-kernel, Matthew Garrett, acpi4asus-user, platform-driver-x86
On Mon, Aug 8, 2011 at 11:16 AM, Axel Lin <axel.lin@gmail.com> wrote:
> This patch fixes wrong test for successful registered led_classdev,
> and also fixes a leak due to missing led_classdev_unregister call
> for asus->kbd_led in asus_wmi_led_exit.
>
> 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.
>
> Thus to unregister a successful registered led_classdev, we should check
> (!IS_ERR_OR_NULL(asus->tpd_led.dev)) instead of (asus->tpd_led.dev).
>
> we use IS_ERR_OR_NULL instead of IS_ERR because if we havn't call
> led_classdev_register, the led_cdev->dev is NULL.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Corentin Chary <corentin.chary@gmail.com>
> ---
> drivers/platform/x86/asus-wmi.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 95cba9e..d1049ee 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -453,7 +453,9 @@ static enum led_brightness kbd_led_get(struct led_classdev *led_cdev)
>
> static void asus_wmi_led_exit(struct asus_wmi *asus)
> {
> - if (asus->tpd_led.dev)
> + if (!IS_ERR_OR_NULL(asus->kbd_led.dev))
> + led_classdev_unregister(&asus->kbd_led);
> + if (!IS_ERR_OR_NULL(asus->tpd_led.dev))
> led_classdev_unregister(&asus->tpd_led);
> if (asus->led_workqueue)
> destroy_workqueue(asus->led_workqueue);
> --
> 1.7.4.1
>
>
>
>
--
Corentin Chary
http://xf.iksaif.net
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] platform-drivers-x86: asus-laptop: fix wrong test for successful registered led_classdev
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
0 siblings, 0 replies; 6+ messages in thread
From: Corentin Chary @ 2011-08-08 12:18 UTC (permalink / raw)
To: Axel Lin
Cc: linux-kernel, Matthew Garrett, acpi4asus-user, platform-driver-x86
On Mon, Aug 8, 2011 at 11:17 AM, Axel Lin <axel.lin@gmail.com> wrote:
> 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.
>
> Thus to unregister a successful registered led_classdev, we should check
> IS_ERR_OR_NULL macro for led_cdev->dev instead of checking if led_cdev->dev
> is NULL or not.
>
> we use IS_ERR_OR_NULL instead of IS_ERR because if we havn't call
> led_classdev_register, the led_cdev->dev is NULL.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Corentin Chary <corentin.chary@gmail.com>
> ---
> drivers/platform/x86/asus-laptop.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index fa6d7ec..0e071fa 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -430,17 +430,17 @@ static enum led_brightness asus_kled_cdev_get(struct led_classdev *led_cdev)
>
> static void asus_led_exit(struct asus_laptop *asus)
> {
> - if (asus->mled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->mled.led.dev))
> led_classdev_unregister(&asus->mled.led);
> - if (asus->tled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->tled.led.dev))
> led_classdev_unregister(&asus->tled.led);
> - if (asus->pled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->pled.led.dev))
> led_classdev_unregister(&asus->pled.led);
> - if (asus->rled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->rled.led.dev))
> led_classdev_unregister(&asus->rled.led);
> - if (asus->gled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->gled.led.dev))
> led_classdev_unregister(&asus->gled.led);
> - if (asus->kled.led.dev)
> + if (!IS_ERR_OR_NULL(asus->kled.led.dev))
> led_classdev_unregister(&asus->kled.led);
> if (asus->led_workqueue) {
> destroy_workqueue(asus->led_workqueue);
> --
> 1.7.4.1
>
>
>
>
--
Corentin Chary
http://xf.iksaif.net
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-08 12:18 UTC | newest]
Thread overview: 6+ 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:17 ` [PATCH 1/3] platform-drivers-x86: eeepc-laptop: " Corentin Chary
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).