]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: stm32f7: prevent array underflow in stm32f7_get_lower_rate()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 29 Apr 2020 13:23:23 +0000 (16:23 +0300)
committerWolfram Sang <wsa@the-dreams.de>
Thu, 30 Apr 2020 14:07:14 +0000 (16:07 +0200)
commit1b932b7ba6be312098ab7bd0c307c18ddb5fff0c
tree921ea499bf24bf3f535b7718e75aa53c78bbd8f1
parent8aec6e40d6317c401e8c0ee2caa27b8a5ec966fd
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: 3b7bdf08861d ("i2c: stm32f7: allows for any bus frequency")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Alain Volmat <alain.volmat@st.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-stm32f7.c