* [PATCH] ASoC: cs42l52: Fix off-by-one boundary checking for cs42l52_get_clk()
@ 2012-12-16 2:11 Axel Lin
2012-12-16 14:10 ` Axel Lin
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-12-16 2:11 UTC (permalink / raw)
To: Mark Brown; +Cc: Brian Austin, Georgi Vlaev, alsa-devel, Liam Girdwood
The caller uses the return value of cs42l52_get_clk as array index,
the valid array index is 0 .. ARRAY_SIZE(clk_map_table) - 1.
Thus we need to ensure ret is less than ARRAY_SIZE(clk_map_table).
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
sound/soc/codecs/cs42l52.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 99bb1c6..66817f6 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -749,7 +749,7 @@ static int cs42l52_get_clk(int mclk, int rate)
}
}
}
- if (ret > ARRAY_SIZE(clk_map_table))
+ if (ret >= ARRAY_SIZE(clk_map_table))
return -EINVAL;
return ret;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: cs42l52: Fix off-by-one boundary checking for cs42l52_get_clk()
2012-12-16 2:11 [PATCH] ASoC: cs42l52: Fix off-by-one boundary checking for cs42l52_get_clk() Axel Lin
@ 2012-12-16 14:10 ` Axel Lin
0 siblings, 0 replies; 2+ messages in thread
From: Axel Lin @ 2012-12-16 14:10 UTC (permalink / raw)
To: Mark Brown; +Cc: Brian Austin, Georgi Vlaev, alsa-devel, Liam Girdwood
2012/12/16 Axel Lin <axel.lin@ingics.com>
> The caller uses the return value of cs42l52_get_clk as array index,
> the valid array index is 0 .. ARRAY_SIZE(clk_map_table) - 1.
> Thus we need to ensure ret is less than ARRAY_SIZE(clk_map_table).
>
Just check the code again, ret is always less than ARRAY_SIZE -1.
I think what we missed here is the case no rate is matched.
Axel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-12-16 14:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-16 2:11 [PATCH] ASoC: cs42l52: Fix off-by-one boundary checking for cs42l52_get_clk() Axel Lin
2012-12-16 14:10 ` Axel Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.