mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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 <[email protected]> Cc: Jean Delvare <[email protected]> Cc: Johannes Berg <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
This commit is contained in:
parent
5da5b6f9e9
commit
18c4078489
2 changed files with 21 additions and 0 deletions
|
|
@ -897,6 +897,15 @@ static int tas_create(struct i2c_adapter *adapter,
|
|||
client = i2c_new_device(adapter, &info);
|
||||
if (!client)
|
||||
return -ENODEV;
|
||||
/*
|
||||
* We know the driver is already loaded, so the device should be
|
||||
* already bound. If not it means binding failed, and then there
|
||||
* is no point in keeping the device instantiated.
|
||||
*/
|
||||
if (!client->driver) {
|
||||
i2c_unregister_device(client);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* Let i2c-core delete that device on driver removal.
|
||||
|
|
|
|||
Loading…
Reference in a new issue