Skip to contentSkip to conversation

pci: fix a missing check of snd_i2c_sendbytes

PATCH In review Kangjie Lu 2 participants 2 messages Dec 26, 2018 – Jan 1, 2019 Sound

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 pci: fix a missing check of snd_i2c_sendbytes

snd_i2c_sendbytes could fail. The fix checks its return value: if it fails, issues an error message and returns with its error code.

---
 sound/pci/ice1712/ews.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/pci/ice1712/ews.c +4 -1
index b8af747ecb43..b978cdb0fc20 100644
@@ -826,7 +826,10 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg
 
 	snd_i2c_lock(ice->i2c);
 	byte = reg;
-	snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
+	if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1)) {
+		dev_err(ice->card->dev, "cannot send pca\n");
+		return -EIO;
+	}
 	byte = 0;
 	if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
 		snd_i2c_unlock(ice->i2c);
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Quoted 14 lines · Kangjie Lu

snd_i2c_sendbytes could fail. The fix checks its return value: if it fails, issues an error message and returns with its error code.

---
 sound/pci/ice1712/ews.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/pci/ice1712/ews.c +0 -0
index b8af747ecb43..b978cdb0fc20 100644

sound/pci/ice1712/ews.c static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg · line 831

Quoted 7 lines
sound/pci/ice1712/ews.c +3 -1
@@ -826,7 +826,10 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg
 
 	snd_i2c_lock(ice->i2c);
 	byte = reg;
-	snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
+	if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1)) {
+		dev_err(ice->card->dev, "cannot send pca\n");
+		return -EIO;

You forgot to unlock before returning.

thanks,

Takashi