Skip to contentSkip to conversation

hda: check make_exec_verb() return value

PATCH In review Greg Thelen 2 participants 2 messages Jun 13, 2011 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hda: check make_exec_verb() return value

If given a -1 cmd parameter then make_exec_verb() returns -1 without setting the res output value.

Prior to this change snd_hda_codec_read() assumed that make_exec_verb() unconditionally set res regardless of the cmd value.

This change explicitly checks the make_exec_verb() return value before consuming the potentially unset res value.

---
 sound/pci/hda/hda_codec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
sound/pci/hda/hda_codec.c +2 -1
index 45b4a8d..f06dd5f 100644
@@ -243,7 +243,8 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
 {
 	unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm);
 	unsigned int res;
-	codec_exec_verb(codec, cmd, &res);
+	if (codec_exec_verb(codec, cmd, &res))
+		return -1;
 	return res;
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_read);
Signature · 1 line
1.7.3.1
#1 lore raw

At Mon, 13 Jun 2011 07:45:45 -0700,

Quoted 11 lines · Greg Thelen

If given a -1 cmd parameter then make_exec_verb() returns -1 without setting the res output value.

Prior to this change snd_hda_codec_read() assumed that make_exec_verb() unconditionally set res regardless of the cmd value.

This change explicitly checks the make_exec_verb() return value before consuming the potentially unset res value.

Applied now. Thanks.

Takashi

Quoted 21 lines
---
 sound/pci/hda/hda_codec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
sound/pci/hda/hda_codec.c +2 -1
index 45b4a8d..f06dd5f 100644
@@ -243,7 +243,8 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
 {
 	unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm);
 	unsigned int res;
-	codec_exec_verb(codec, cmd, &res);
+	if (codec_exec_verb(codec, cmd, &res))
+		return -1;
 	return res;
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_read);
Signature · 1 line
1.7.3.1