From: Geert Uytterhoeven Date: Thu, 9 Mar 2017 11:28:18 +0000 (+0100) Subject: base: soc: Let soc_device_match() return no match when called too early X-Git-Tag: v4.12-rc1~54^2~2^2~4 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=0656db9e445a12122f76e259ab89d256cb07a0ad;p=linux.git base: soc: Let soc_device_match() return no match when called too early 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 Acked-by: Arnd Bergmann --- diff --git a/drivers/base/soc.c b/drivers/base/soc.c index dc26e5949a32..50033081834a 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -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