diff mbox

[2/5] hda-emu: Quit early if requested codec index is above limit

Message ID 1409833267-9778-3-git-send-email-david.henningsson@canonical.com (mailing list archive)
State Accepted
Delegated to: Takashi Iwai
Headers show

Commit Message

David Henningsson Sept. 4, 2014, 12:21 p.m. UTC
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
 hda-parse.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

diff --git a/hda-parse.c b/hda-parse.c
index d9fc311..57e9ee3 100644
--- a/hda-parse.c
+++ b/hda-parse.c
@@ -687,6 +687,11 @@  int parse_codec_proc(FILE *fp, struct xhda_codec *codecp, int codec_index)
 		}
 	}
 
+	if (curidx < codec_index) {
+		hda_log(HDA_LOG_ERR, "Codec index %d requested, but found only %d codecs\n", codec_index, curidx+1);
+		return -ENODEV;
+	}
+
 	add_codec_extensions(codec);
 
 	return 0;