lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1292490353.9368.2.camel@mola>
Date:	Thu, 16 Dec 2010 17:05:53 +0800
From:	Axel Lin <axel.lin@...il.com>
To:	linux-kernel <linux-kernel@...r.kernel.org>
Cc:	Riku Voipio <riku.voipio@....fi>,
	Richard Purdie <rpurdie@...ys.net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Dmitry Torokhov <dtor@...l.ru>
Subject: [PATCH] leds: leds-pca9532 cleanups

>>From 6244111ba78a6768ded3fedf8967b6bc891fa757 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@...il.com>
Date: Thu, 16 Dec 2010 15:41:55 +0800
Subject: [PATCH] leds: leds-pca9532 cleanups

This patch includes below fixes:
1. Remove unneeded input_free_device() after input_unregister_device().
2. Use "while (--i >= 0)" instead of "if (i > 0) for (i = i - 1; i >= 0; i--)"
   for reclaim resources in pca9532_configure() error path.
   I think this change improves readability.

Signed-off-by: Axel Lin <axel.lin@...il.com>
---
 drivers/leds/leds-pca9532.c |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 43d0875..c298c65 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -274,24 +274,23 @@ static int pca9532_configure(struct i2c_client *client,
 	return 0;
 
 exit:
-	if (i > 0)
-		for (i = i - 1; i >= 0; i--)
-			switch (data->leds[i].type) {
-			case PCA9532_TYPE_NONE:
-				break;
-			case PCA9532_TYPE_LED:
-				led_classdev_unregister(&data->leds[i].ldev);
-				cancel_work_sync(&data->leds[i].work);
-				break;
-			case PCA9532_TYPE_N2100_BEEP:
-				if (data->idev != NULL) {
-					input_unregister_device(data->idev);
-					input_free_device(data->idev);
-					cancel_work_sync(&data->work);
-					data->idev = NULL;
-				}
-				break;
+	while (--i >= 0) {
+		switch (data->leds[i].type) {
+		case PCA9532_TYPE_NONE:
+			break;
+		case PCA9532_TYPE_LED:
+			led_classdev_unregister(&data->leds[i].ldev);
+			cancel_work_sync(&data->leds[i].work);
+			break;
+		case PCA9532_TYPE_N2100_BEEP:
+			if (data->idev != NULL) {
+				input_unregister_device(data->idev);
+				cancel_work_sync(&data->work);
+				data->idev = NULL;
 			}
+			break;
+		}
+	}
 
 	return err;
 }
@@ -341,7 +340,6 @@ static int pca9532_remove(struct i2c_client *client)
 		case PCA9532_TYPE_N2100_BEEP:
 			if (data->idev != NULL) {
 				input_unregister_device(data->idev);
-				input_free_device(data->idev);
 				cancel_work_sync(&data->work);
 				data->idev = NULL;
 			}
-- 
1.7.2



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ