aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-10-01 01:46:33 -0400
committerTakashi Iwai <tiwai@suse.de>2009-10-01 01:46:33 -0400
commit18c4078489fe064cc0ed08be3381cf2f26657f5f (patch)
tree72d5534c800da85393209a39d335af2d5606c695 /sound
parent5da5b6f9e967e8c62486444f97e66252c3768d7d (diff)
ALSA: Don't assume i2c device probing always succeeds
The client->driver pointer can be NULL when i2c-device probing fails in i2c_new_device(). This patch adds the NULL checks for client->driver and return the error instead of blind assumption of driver availability. Reported-by: Tim Shepard <shep@alum.mit.edu> Cc: Jean Delvare <khali@linux-fr.org> Cc: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/aoa/codecs/tas.c9
-rw-r--r--sound/ppc/keywest.c12
2 files changed, 21 insertions, 0 deletions
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index f0ebc971c686..1dd66ddffcaf 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -897,6 +897,15 @@ static int tas_create(struct i2c_adapter *adapter,
897 client = i2c_new_device(adapter, &info); 897 client = i2c_new_device(adapter, &info);
898 if (!client) 898 if (!client)
899 return -ENODEV; 899 return -ENODEV;
900 /*
901 * We know the driver is already loaded, so the device should be
902 * already bound. If not it means binding failed, and then there
903 * is no point in keeping the device instantiated.
904 */
905 if (!client->driver) {
906 i2c_unregister_device(client);
907 return -ENODEV;
908 }
900 909
901 /* 910 /*
902 * Let i2c-core delete that device on driver removal. 911 * Let i2c-core delete that device on driver removal.
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c
index 835fa19ed461..bb6819aab133 100644
--- a/sound/ppc/keywest.c
+++ b/sound/ppc/keywest.c
@@ -59,6 +59,18 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter)
59 strlcpy(info.type, "keywest", I2C_NAME_SIZE); 59 strlcpy(info.type, "keywest", I2C_NAME_SIZE);
60 info.addr = keywest_ctx->addr; 60 info.addr = keywest_ctx->addr;
61 keywest_ctx->client = i2c_new_device(adapter, &info); 61 keywest_ctx->client = i2c_new_device(adapter, &info);
62 if (!keywest_ctx->client)
63 return -ENODEV;
64 /*
65 * We know the driver is already loaded, so the device should be
66 * already bound. If not it means binding failed, and then there
67 * is no point in keeping the device instantiated.
68 */
69 if (!keywest_ctx->client->driver) {
70 i2c_unregister_device(keywest_ctx->client);
71 keywest_ctx->client = NULL;
72 return -ENODEV;
73 }
62 74
63 /* 75 /*
64 * Let i2c-core delete that device on driver removal. 76 * Let i2c-core delete that device on driver removal.