diff options
author | Dan Carpenter <error27@gmail.com> | 2010-06-28 11:34:24 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-06-28 11:35:15 -0700 |
commit | 1796b983cc4cbbed5e9e478b03591609a2c21987 (patch) | |
tree | 2cbb7e583d38a76cbf0f036857350deb8c5216f6 /drivers/input | |
parent | 28ed684fa3c0a75b59a00e209afef98aff7fa617 (diff) | |
download | blackbird-op-linux-1796b983cc4cbbed5e9e478b03591609a2c21987.tar.gz blackbird-op-linux-1796b983cc4cbbed5e9e478b03591609a2c21987.zip |
Input: lm8323 - fix error handling in lm8323_probe()
We reuse the "i" variable later on so if we goto fail3 or fail4
then "i" will be set to the wrong thing and cause a crash.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/lm8323.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index bc696931fed7..6ecd37a845f2 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c @@ -642,6 +642,7 @@ static int __devinit lm8323_probe(struct i2c_client *client, struct lm8323_platform_data *pdata = client->dev.platform_data; struct input_dev *idev; struct lm8323_chip *lm; + int pwm; int i, err; unsigned long tmo; u8 data[2]; @@ -710,8 +711,9 @@ static int __devinit lm8323_probe(struct i2c_client *client, goto fail1; } - for (i = 0; i < LM8323_NUM_PWMS; i++) { - err = init_pwm(lm, i + 1, &client->dev, pdata->pwm_names[i]); + for (pwm = 0; pwm < LM8323_NUM_PWMS; pwm++) { + err = init_pwm(lm, pwm + 1, &client->dev, + pdata->pwm_names[pwm]); if (err < 0) goto fail2; } @@ -764,9 +766,9 @@ fail4: fail3: device_remove_file(&client->dev, &dev_attr_disable_kp); fail2: - while (--i >= 0) - if (lm->pwm[i].enabled) - led_classdev_unregister(&lm->pwm[i].cdev); + while (--pwm >= 0) + if (lm->pwm[pwm].enabled) + led_classdev_unregister(&lm->pwm[pwm].cdev); fail1: input_free_device(idev); kfree(lm); |