From patchwork Thu Jun 10 07:54:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 105305 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5A7sulI020204 for ; Thu, 10 Jun 2010 07:54:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756976Ab0FJHy4 (ORCPT ); Thu, 10 Jun 2010 03:54:56 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:56284 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524Ab0FJHyz (ORCPT ); Thu, 10 Jun 2010 03:54:55 -0400 Received: by wyb40 with SMTP id 40so754612wyb.19 for ; Thu, 10 Jun 2010 00:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=xMN1iPkb/eZQ3xWhjEkcDxzUWVGCs7eJ8gjs8dg8Zdw=; b=COXeSje7+tTCuTzxC+IH2OkQkIyyR87SySzyFI6bHaac8K1Vzdji9j6CFv8qnJTr7k EMLw7X4peXRYbFI6SuctS9DvL1nWEqb/8+B/laMjiCYvDCAqQR0IvrN2ljQoDZpY1jqi Hk2nunezvd1y8A/crWYSVq3Ux6/MfLUyH6Vfk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=LFZgBnZpp6bhUIIUnBkO6DhDZmn5lO7BZG6A5f9xH/DHB1ZQTk75V07DrbFkKWvsU6 asWXbWY9ANPxMd+riokbNHLCW+AdgJCLFuq56cAXWXAgVGUpNbkUeIyCVkO3SGPx7n6P L/flB9EAOu6z9FNWY3A0aQNk1BchaBqEGg/84= Received: by 10.227.151.66 with SMTP id b2mr4185414wbw.158.1276156492176; Thu, 10 Jun 2010 00:54:52 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id t15sm1075781wbc.23.2010.06.10.00.54.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 10 Jun 2010 00:54:51 -0700 (PDT) Date: Thu, 10 Jun 2010 09:54:31 +0200 From: Dan Carpenter To: Dmitry Torokhov Cc: Wolfram Sang , Richard Purdie , Mark Brown , linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] input: error handling bug in lm8323_probe() Message-ID: <20100610075431.GK5483@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 10 Jun 2010 07:54:57 +0000 (UTC) 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);