提交 08736e83 编写于 作者: D Dan Carpenter 提交者: Wolfram Sang

i2c: stm32f7: prevent array underflow in stm32f7_get_lower_rate()

We want to break with "i" set to zero whether we find the rate we want
or not.  In the current code, if we don't find the rate we want then it
exits the loop with "i" set to -1 and results in an array underflow.

Fixes: 09cc9a3b ("i2c: stm32f7: allows for any bus frequency")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NAlain Volmat <alain.volmat@st.com>
Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
上级 84c0eb21
......@@ -607,7 +607,7 @@ static u32 stm32f7_get_lower_rate(u32 rate)
{
int i = ARRAY_SIZE(stm32f7_i2c_specs);
while (i--)
while (--i)
if (stm32f7_i2c_specs[i].rate < rate)
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部