Commit 1796b983 authored by Dan Carpenter's avatar Dan Carpenter Committed by Dmitry Torokhov

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: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 28ed684f
...@@ -642,6 +642,7 @@ static int __devinit lm8323_probe(struct i2c_client *client, ...@@ -642,6 +642,7 @@ static int __devinit lm8323_probe(struct i2c_client *client,
struct lm8323_platform_data *pdata = client->dev.platform_data; struct lm8323_platform_data *pdata = client->dev.platform_data;
struct input_dev *idev; struct input_dev *idev;
struct lm8323_chip *lm; struct lm8323_chip *lm;
int pwm;
int i, err; int i, err;
unsigned long tmo; unsigned long tmo;
u8 data[2]; u8 data[2];
...@@ -710,8 +711,9 @@ static int __devinit lm8323_probe(struct i2c_client *client, ...@@ -710,8 +711,9 @@ static int __devinit lm8323_probe(struct i2c_client *client,
goto fail1; goto fail1;
} }
for (i = 0; i < LM8323_NUM_PWMS; i++) { for (pwm = 0; pwm < LM8323_NUM_PWMS; pwm++) {
err = init_pwm(lm, i + 1, &client->dev, pdata->pwm_names[i]); err = init_pwm(lm, pwm + 1, &client->dev,
pdata->pwm_names[pwm]);
if (err < 0) if (err < 0)
goto fail2; goto fail2;
} }
...@@ -764,9 +766,9 @@ static int __devinit lm8323_probe(struct i2c_client *client, ...@@ -764,9 +766,9 @@ static int __devinit lm8323_probe(struct i2c_client *client,
fail3: fail3:
device_remove_file(&client->dev, &dev_attr_disable_kp); device_remove_file(&client->dev, &dev_attr_disable_kp);
fail2: fail2:
while (--i >= 0) while (--pwm >= 0)
if (lm->pwm[i].enabled) if (lm->pwm[pwm].enabled)
led_classdev_unregister(&lm->pwm[i].cdev); led_classdev_unregister(&lm->pwm[pwm].cdev);
fail1: fail1:
input_free_device(idev); input_free_device(idev);
kfree(lm); kfree(lm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment