diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-10-04 16:53:46 -0400 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2009-10-04 16:53:46 -0400 |
commit | 6f6b35e133fe4313277b30fc1a7ea313875ea6c9 (patch) | |
tree | 1b7aa0dde7d69b0f90b80a0398c9699faae6260e /drivers/macintosh/therm_adt746x.c | |
parent | 18669eabde2ff5fc446e72e043f0539059763438 (diff) |
macintosh: Don't assume i2c device probing always succeeds
If i2c device probing fails, then there is no driver to dereference
after calling i2c_new_device(). Stop assuming that probing will always
succeed, to avoid NULL pointer dereferences. We have an easier access
to the driver anyway.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Tim Shepard <shep@alum.mit.edu>
Cc: Colin Leroy <colin@colino.net>
Diffstat (limited to 'drivers/macintosh/therm_adt746x.c')
-rw-r--r-- | drivers/macintosh/therm_adt746x.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index fde377c60cca..556f0feaa4df 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -124,6 +124,8 @@ read_reg(struct thermostat* th, int reg) | |||
124 | return data; | 124 | return data; |
125 | } | 125 | } |
126 | 126 | ||
127 | static struct i2c_driver thermostat_driver; | ||
128 | |||
127 | static int | 129 | static int |
128 | attach_thermostat(struct i2c_adapter *adapter) | 130 | attach_thermostat(struct i2c_adapter *adapter) |
129 | { | 131 | { |
@@ -148,7 +150,7 @@ attach_thermostat(struct i2c_adapter *adapter) | |||
148 | * Let i2c-core delete that device on driver removal. | 150 | * Let i2c-core delete that device on driver removal. |
149 | * This is safe because i2c-core holds the core_lock mutex for us. | 151 | * This is safe because i2c-core holds the core_lock mutex for us. |
150 | */ | 152 | */ |
151 | list_add_tail(&client->detected, &client->driver->clients); | 153 | list_add_tail(&client->detected, &thermostat_driver.clients); |
152 | return 0; | 154 | return 0; |
153 | } | 155 | } |
154 | 156 | ||