]> git.karo-electronics.de Git - karo-tx-linux.git/commit
of: Fix NULL dereference in selftest removal code
authorGrant Likely <grant.likely@linaro.org>
Wed, 1 Oct 2014 15:57:07 +0000 (16:57 +0100)
committerGrant Likely <grant.likely@linaro.org>
Wed, 1 Oct 2014 16:01:43 +0000 (17:01 +0100)
commite66c98c7a0eacc33a9369a3ec086740044eb986c
tree639990268861bd1aae22d93b6f92bbbd47768192
parentfe82dcec644244676d55a1384c958d5f67979adb
of: Fix NULL dereference in selftest removal code

The selftest code removes its testcase data from the live tree when
exiting, but if the testcases data tree contains an empty child of the
root, then it causes an oops due to a NULL dereference. The reason is
that the code tries to directly dereference the child pointer without
checking first if a child is actually there.

The solution is to pass the parent node into detach_node_and_children()
instead of trying to pass the child. This required removing the code
that attempts to remove all of the sibling nodes in
detach_node_and_children(), which was never sensible in the first place.

At the same time add a check to make sure the bounds of the nodes list
are not exceeded by the testdata tree. If they are then abort.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
drivers/of/selftest.c