]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
base: soc: Let soc_device_match() return no match when called too early
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 9 Mar 2017 11:28:18 +0000 (12:28 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 29 Mar 2017 19:43:22 +0000 (21:43 +0200)
If soc_device_match() is called before the SoC bus has been registered,
bus_for_each_dev() returns -EINVAL, which is considered a match, as it
is non-zero.

While calling soc_device_match() too early can be considered an
integration mistake, returning a match is counter-intuitive:
soc_device_match() is typically used to handle quirks, i.e. to deviate
from the default path.  Hence add a check to abort checking and return
no match instead.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Arnd Bergmann <arnd@arndb.de>
drivers/base/soc.c

index dc26e5949a3202233ddbeecd6921cd3f1488120b..50033081834a9ccd53f20aee6ecb1072d820990b 100644 (file)
@@ -230,6 +230,8 @@ const struct soc_device_attribute *soc_device_match(
                        break;
                ret = bus_for_each_dev(&soc_bus_type, NULL, (void *)matches,
                                       soc_device_match_one);
+               if (ret < 0)
+                       return NULL;
                if (!ret)
                        matches++;
                else