mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pci: fix a missing check of snd_i2c_sendbytes
@ 2018-12-26  5:12 Kangjie Lu
  2019-01-01  9:02 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-26  5:12 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

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

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 sound/pci/ice1712/ews.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index b8af747ecb43..b978cdb0fc20 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -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);
-- 
2.17.2 (Apple Git-113)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pci: fix a missing check of snd_i2c_sendbytes
  2018-12-26  5:12 [PATCH] pci: fix a missing check of snd_i2c_sendbytes Kangjie Lu
@ 2019-01-01  9:02 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2019-01-01  9:02 UTC (permalink / raw)
  To: Kangjie Lu; +Cc: alsa-devel, Jaroslav Kysela, pakki001, linux-kernel

On Wed, 26 Dec 2018 06:12:04 +0100,
Kangjie Lu wrote:
> 
> snd_i2c_sendbytes could fail. The fix checks its return value: if it
> fails, issues an error message and returns with its error code.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  sound/pci/ice1712/ews.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
> index b8af747ecb43..b978cdb0fc20 100644
> --- a/sound/pci/ice1712/ews.c
> +++ b/sound/pci/ice1712/ews.c
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-01  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-26  5:12 [PATCH] pci: fix a missing check of snd_i2c_sendbytes Kangjie Lu
2019-01-01  9:02 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®