]> git.baikalelectronics.ru Git - kernel.git/commit
of/selftest: Fix off-by-one error in removal path
authorGrant Likely <grant.likely@linaro.org>
Wed, 19 Nov 2014 16:22:32 +0000 (16:22 +0000)
committerGrant Likely <grant.likely@linaro.org>
Wed, 19 Nov 2014 17:42:57 +0000 (17:42 +0000)
commit9793e0896beee74b40c498f12b2b335a3c1fab23
treea7234d01a8647f98e644e89a3b2675b2de4e1c30
parentedd93c0a203c82cba4ac70953e5123d749a9b7f0
of/selftest: Fix off-by-one error in removal path

The removal path for selftest data has an off by one error that causes
the code to dereference beyond the end of the nodes[] array on the first
pass through. The old code only worked by chance on a lot of platforms,
but the bug was recently exposed on aarch64.

The fix is simple. Decrement the node count before dereferencing, not
after.

Reported-by: Kevin Hilman <khilman@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
Cc: <stable@vger.kernel.org> # v3.17+
drivers/of/selftest.c