Re: [PATCH 1/3] platform-drivers-x86: eeepc-laptop: fix wrong testfor successful registered led_classdev

From: Corentin Chary
Date: Mon Aug 08 2011 - 08:18:07 EST


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@xxxxxxxxx> 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@xxxxxxxxx>

Acked-by: Corentin Chary <corentin.chary@xxxxxxxxx>

> ---
> Â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@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>



--
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/