checks: fix simple-bus compatible matching

Since commit 7975f64222 ("Fix widespread incorrect use of strneq(),
replace with new strprefixeq()") simple-bus checks have been silently
skipped. The problem was 'end - str' is one more than the string length
and the strnlen in strprefixeq fails. This can't be fixed simply by
subtracting one as it is possible to have multiple '\0' at the end of
the property. Fix this by making the 'compatible' property string list
check a dependency, and then we can assume the property is null
terminated and we can just use streq() for comparisons.

Add some tests so the problem doesn't happen again.

Fixes: 7975f64222 ("Fix widespread incorrect use of strneq(), replace with new strprefixeq()")
Reported-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Rob Herring 2018-09-20 14:30:03 -07:00 committed by David Gibson
parent 8c59a97ce0
commit e84742aa7b
4 changed files with 43 additions and 2 deletions

View file

@ -0,0 +1,18 @@
/dts-v1/;
/ {
#address-cells = <1>;
#size-cells = <1>;
bus@10000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "foo-bus", "simple-bus";
ranges = <0x0 0x10000000 0x10000>;
node@100 {
reg = <0x1000 1>;
};
};
};