Subject: I2C hwmon: kfree fixes

From: "Mark M. Hoffman" <[email-masked]>
Date: Fri, 15 Jul 2005 21:36:50 -0400

This patch fixes several instances of hwmon drivers kfree'ing the
"wrong" pointer; the existing code works somewhat by accident.

Signed-off-by: Mark M. Hoffman <[email-masked]>
Signed-off-by: Jean Delvare <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>

---
 drivers/hwmon/adm1026.c    |    4 ++--
 drivers/hwmon/adm1031.c    |    4 ++--
 drivers/hwmon/adm9240.c    |    2 +-
 drivers/hwmon/smsc47b397.c |    2 +-
 drivers/hwmon/smsc47m1.c   |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

--- gregkh-2.6.orig/drivers/hwmon/adm1026.c	2005-07-26 14:53:45.000000000 -0700
+++ gregkh-2.6/drivers/hwmon/adm1026.c	2005-07-26 14:56:38.000000000 -0700
@@ -325,7 +325,7 @@
 int adm1026_detach_client(struct i2c_client *client)
 {
 	i2c_detach_client(client);
-	kfree(client);
+	kfree(i2c_get_clientdata(client));
 	return 0;
 }
 
@@ -1691,7 +1691,7 @@
 
 	/* Error out and cleanup code */
 exitfree:
-	kfree(new_client);
+	kfree(data);
 exit:
 	return err;
 }
--- gregkh-2.6.orig/drivers/hwmon/adm1031.c	2005-07-13 09:45:05.000000000 -0700
+++ gregkh-2.6/drivers/hwmon/adm1031.c	2005-07-26 14:56:38.000000000 -0700
@@ -834,7 +834,7 @@
 	return 0;
 
 exit_free:
-	kfree(new_client);
+	kfree(data);
 exit:
 	return err;
 }
@@ -845,7 +845,7 @@
 	if ((ret = i2c_detach_client(client)) != 0) {
 		return ret;
 	}
-	kfree(client);
+	kfree(i2c_get_clientdata(client));
 	return 0;
 }
 
--- gregkh-2.6.orig/drivers/hwmon/adm9240.c	2005-07-13 09:45:05.000000000 -0700
+++ gregkh-2.6/drivers/hwmon/adm9240.c	2005-07-26 14:56:38.000000000 -0700
@@ -616,7 +616,7 @@
 
 	return 0;
 exit_free:
-	kfree(new_client);
+	kfree(data);
 exit:
 	return err;
 }
--- gregkh-2.6.orig/drivers/hwmon/smsc47b397.c	2005-07-13 09:45:05.000000000 -0700
+++ gregkh-2.6/drivers/hwmon/smsc47b397.c	2005-07-26 14:56:38.000000000 -0700
@@ -298,7 +298,7 @@
 	return 0;
 
 error_free:
-	kfree(new_client);
+	kfree(data);
 error_release:
 	release_region(addr, SMSC_EXTENT);
 	return err;
--- gregkh-2.6.orig/drivers/hwmon/smsc47m1.c	2005-07-13 09:45:05.000000000 -0700
+++ gregkh-2.6/drivers/hwmon/smsc47m1.c	2005-07-26 14:56:38.000000000 -0700
@@ -495,7 +495,7 @@
 	return 0;
 
 error_free:
-	kfree(new_client);
+	kfree(data);
 error_release:
 	release_region(address, SMSC_EXTENT);
 	return err;