From: Dan Carpenter <error27@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>,
Richard Purdie <rpurdie@linux.intel.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] input: error handling bug in lm8323_probe()
Date: Thu, 10 Jun 2010 09:54:31 +0200 [thread overview]
Message-ID: <20100610075431.GK5483@bicker> (raw)
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>
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index 40b032f..f7c2a16 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);
next reply other threads:[~2010-06-10 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-10 7:54 Dan Carpenter [this message]
2010-06-29 7:07 ` [patch] input: error handling bug in lm8323_probe() Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100610075431.GK5483@bicker \
--to=error27@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=rpurdie@linux.intel.com \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).