leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
PATCH v2 1/1 leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
In current implementation, lp3944_probe return 0 even if lp3944_configure fail. Therefore, led_classdev_unregister will be executed twice
( in error handling of lp3944_configure and lp3944_remove ).
This patch properly handles lp3944_configure fail in lp3944_probe.
--- drivers/leds/leds-lp3944.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/leds/leds-lp3944.c +7 -2
@@ -379,6 +379,7 @@ static int __devinit lp3944_probe(struct i2c_client *client, {struct lp3944_platform_data *lp3944_pdata = client->dev.platform_data;struct lp3944_data *data; +int err;if (lp3944_pdata ==NULL ) {dev_err (&client->dev,"no platform data\n" );
@@ -401,9 +402,13 @@ static int __devinit lp3944_probe(struct i2c_client *client,mutex_init (&data->lock); -dev_info (&client->dev,"lp3944 enabled\n" ); + err =lp3944_configure (client, data, lp3944_pdata); +if (err <0 ) { +kfree (data); +return err; + } -lp3944_configure (client, data, lp3944_pdata); +dev_info (&client->dev,"lp3944 enabled\n" );return 0 ; }
Signature · 1 line
1.5.4.3
Quoted 6 lines · Axel Lin
In current implementation,
lp3944_probereturn 0 even iflp3944_configurefail. Therefore,led_classdev_unregisterwill be executed twice
( in error handling oflp3944_configureandlp3944_remove).
This patch properly handleslp3944_configurefail inlp3944_probe.Signed-off-by Axel Lin <[email protected]>
Looks good to me.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 6 lines · On Mon, 17 May 2010 17:47:48 +0800 Axel Lin <[email protected]> wrote:
In current implementation,
lp3944_probereturn 0 even iflp3944_configurefail. Therefore,led_classdev_unregisterwill be executed twice
( in error handling oflp3944_configureandlp3944_remove).
This patch properly handleslp3944_configurefail inlp3944_probe.Signed-off-by Axel Lin <[email protected]>
Thanks.
Signature · 10 lines
Antonio Ospite http://ao2.it PGP public key ID: 0x4553B001 A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?
Richard Purdie
AppliedQuoted 12 lines · Antonio Ospite
Quoted 6 lines · On Mon, 17 May 2010 17:47:48 +0800 Axel Lin <[email protected]> wrote:
In current implementation,
lp3944_probereturn 0 even iflp3944_configurefail. Therefore,led_classdev_unregisterwill be executed twice
( in error handling oflp3944_configureandlp3944_remove).
This patch properly handleslp3944_configurefail inlp3944_probe.Signed-off-by Axel Lin <[email protected]>Acked-by Antonio Ospite <[email protected]>
Queued in the leds tree, thanks.
Richard