diff mbox

[2/2] ASoC: max9867: silence and array overflow warning

Message ID 20160225075038.GC7333@mwanda (mailing list archive)
State Accepted
Commit 90966391005e69a8964350278917a87fe49adf0f
Headers show

Commit Message

Dan Carpenter Feb. 25, 2016, 7:50 a.m. UTC
Smatch complains that we might reach the end of this loop without
finding what we're looking for leading to a buffer overflow.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Axel Lin Feb. 25, 2016, 8:18 a.m. UTC | #1
2016-02-25 15:50 GMT+08:00 Dan Carpenter <dan.carpenter@oracle.com>:
> Smatch complains that we might reach the end of this loop without
> finding what we're looking for leading to a buffer overflow.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Axel Lin <axel.lin@ingics.com>
diff mbox

Patch

diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c
index 4fb6fc7..9fb03c6 100755
--- a/sound/soc/codecs/max9867.c
+++ b/sound/soc/codecs/max9867.c
@@ -156,6 +156,8 @@  static inline int get_ni_value(int mclk, int rate)
 		if (ni_div[i].mclk >= mclk)
 			break;
 	}
+	if (i == ARRAY_SIZE(ni_div))
+		return -EINVAL;
 
 	switch (rate) {
 	case 8000: