]> git.baikalelectronics.ru Git - kernel.git/commit
regulator: ti-abb: Fix array out of bound read access on the first transition
authorNishanth Menon <nm@ti.com>
Wed, 18 Nov 2020 14:50:09 +0000 (08:50 -0600)
committerMark Brown <broonie@kernel.org>
Wed, 18 Nov 2020 17:59:24 +0000 (17:59 +0000)
commit1b1940fe9b59e2f6e617121cb8857c4955f20872
tree70cf6426654a8d633a5512d671f241d39bd6f27e
parent6968a02daeb5094316615320ed7863d218dd8ef3
regulator: ti-abb: Fix array out of bound read access on the first transition

At the start of driver initialization, we do not know what bias
setting the bootloader has configured the system for and we only know
for certain the very first time we do a transition.

However, since the initial value of the comparison index is -EINVAL,
this negative value results in an array out of bound access on the
very first transition.

Since we don't know what the setting is, we just set the bias
configuration as there is nothing to compare against. This prevents
the array out of bound access.

NOTE: Even though we could use a more relaxed check of "< 0" the only
valid values(ignoring cosmic ray induced bitflips) are -EINVAL, 0+.

Fixes: e70bc7119ac6 ("regulator: Introduce TI Adaptive Body Bias(ABB) on-chip LDO driver")
Link: https://lore.kernel.org/linux-mm/CA+G9fYuk4imvhyCN7D7T6PMDH6oNp6HDCRiTUKMQ6QXXjBa4ag@mail.gmail.com/
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Nishanth Menon <nm@ti.com>
Link: https://lore.kernel.org/r/20201118145009.10492-1-nm@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/ti-abb-regulator.c