]> git.hungrycats.org Git - linux/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2014 23:57:29 +0000 (15:57 -0800)
commit1f8d238e13cd3bdc43b1c2623755347a24f4ce7e
treeb7e18df1f043f2b14c5178ea9e29b01ace13daa2
parentb7b660a4ddc1c09b6eec40a5c211d7082aaa2dd4
of/selftest: Fix off-by-one error in removal path

commit c1a2086e2d8c4eb4e8630ba752e911ec180dec67 upstream.

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>
drivers/of/selftest.c