[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220921001414.4046492-1-isaacmanjarres@google.com>
Date: Tue, 20 Sep 2022 17:14:13 -0700
From: "Isaac J. Manjarres" <isaacmanjarres@...gle.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Russell King <rmk+kernel@....linux.org.uk>,
Tomeu Vizoso <tomeu.vizoso@...labora.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Ulf Hansson <ulf.hansson@...aro.org>
Cc: "Isaac J. Manjarres" <isaacmanjarres@...gle.com>,
stable@...r.kernel.org, Saravana Kannan <saravanak@...gle.com>,
kernel-team@...roid.com, linux-kernel@...r.kernel.org
Subject: [PATCH v1] driver core: Fix bus_type.match() error handling in __driver_attach()
When a driver registers with a bus, it will attempt to match with every
device on the bus through the __driver_attach() function. Currently, if
the bus_type.match() function encounters an error that is not
-EPROBE_DEFER, __driver_attach() will return a negative error code, which
causes the driver registration logic to stop trying to match with the
remaining devices on the bus.
This behavior is not correct; a failure while matching a driver to a
device does not mean that the driver won't be able to match and bind
with other devices on the bus. Update the logic in __driver_attach()
to reflect this.
Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()")
Cc: stable@...r.kernel.org
Cc: Saravana Kannan <saravanak@...gle.com>
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@...gle.com>
---
drivers/base/dd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
This problem was not reported anywhere, but rather it was something that
I noticed while looking at this function.
--Isaac
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index ec69b43f926a..6669daf1f31f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1162,7 +1162,11 @@ static int __driver_attach(struct device *dev, void *data)
return 0;
} else if (ret < 0) {
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
- return ret;
+ /*
+ * Driver could not match with device, but may match with
+ * another device on the bus.
+ */
+ return 0;
} /* ret > 0 means positive match */
if (driver_allows_async_probing(drv)) {
--
2.37.3.968.ga6b4b080e4-goog
Powered by blists - more mailing lists