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/windfarm_lm75_sensor.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/windfarm_lm75_sensor.c')
-rw-r--r-- | drivers/macintosh/windfarm_lm75_sensor.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index 529886c7a826..ed6426a10773 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c | |||
@@ -115,6 +115,8 @@ static int wf_lm75_probe(struct i2c_client *client, | |||
115 | return rc; | 115 | return rc; |
116 | } | 116 | } |
117 | 117 | ||
118 | static struct i2c_driver wf_lm75_driver; | ||
119 | |||
118 | static struct i2c_client *wf_lm75_create(struct i2c_adapter *adapter, | 120 | static struct i2c_client *wf_lm75_create(struct i2c_adapter *adapter, |
119 | u8 addr, int ds1775, | 121 | u8 addr, int ds1775, |
120 | const char *loc) | 122 | const char *loc) |
@@ -157,7 +159,7 @@ static struct i2c_client *wf_lm75_create(struct i2c_adapter *adapter, | |||
157 | * Let i2c-core delete that device on driver removal. | 159 | * Let i2c-core delete that device on driver removal. |
158 | * This is safe because i2c-core holds the core_lock mutex for us. | 160 | * This is safe because i2c-core holds the core_lock mutex for us. |
159 | */ | 161 | */ |
160 | list_add_tail(&client->detected, &client->driver->clients); | 162 | list_add_tail(&client->detected, &wf_lm75_driver.clients); |
161 | return client; | 163 | return client; |
162 | fail: | 164 | fail: |
163 | return NULL; | 165 | return NULL; |