Skip to content

Commit c1159f9

Browse files
Jean DelvareJean Delvare
authored andcommitted
i2c: Check for address business before creating clients
We check for address business in i2c_probe_address(), i2c_detect_address() and i2c_new_probed_device(), but this isn't sufficient. Drivers can call i2c_attach_client() and i2c_new_device() on any address, so we must check the address there as well. This fixes bug #11239: http://bugzilla.kernel.org/show_bug.cgi?id=11239 Signed-off-by: Jean Delvare <khali@linux-fr.org>
1 parent 8d24f8d commit c1159f9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/i2c/i2c-core.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,12 @@ static int i2c_check_addr(struct i2c_adapter *adapter, int addr)
813813
int i2c_attach_client(struct i2c_client *client)
814814
{
815815
struct i2c_adapter *adapter = client->adapter;
816-
int res = 0;
816+
int res;
817+
818+
/* Check for address business */
819+
res = i2c_check_addr(adapter, client->addr);
820+
if (res)
821+
return res;
817822

818823
client->dev.parent = &client->adapter->dev;
819824
client->dev.bus = &i2c_bus_type;

0 commit comments

Comments
 (0)