From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753613AbdC2TjT (ORCPT ); Wed, 29 Mar 2017 15:39:19 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:52874 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbdC2TjS (ORCPT ); Wed, 29 Mar 2017 15:39:18 -0400 From: Geert Uytterhoeven To: Arnd Bergmann , Greg Kroah-Hartman , Kevin Hilman , Magnus Damm , Olof Johansson , Simon Horman Cc: linux-renesas-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 1/2] base: soc: Let soc_device_match() return no match when called too early Date: Wed, 29 Mar 2017 21:38:53 +0200 Message-Id: <1490816334-14568-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490816334-14568-1-git-send-email-geert+renesas@glider.be> References: <1490816334-14568-1-git-send-email-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v2: - Drop RFC state, - Add Acked-by, - Add missing "too early" to second paragraph of description. --- drivers/base/soc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/soc.c b/drivers/base/soc.c index dc26e5949a320223..50033081834a9ccd 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 -- 2.7.4