* [PATCH stable-4.14] driver core: Fix bus_type.match() error handling in __driver_attach()
@ 2023-01-10 2:15 Isaac J. Manjarres
2023-01-12 12:52 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Isaac J. Manjarres @ 2023-01-10 2:15 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Marek Szyprowski,
Tomeu Vizoso, Russell King, Ulf Hansson
Cc: Isaac J. Manjarres, stable, Saravana Kannan, kernel-team,
linux-kernel
commit 27c0d217340e47ec995557f61423ef415afba987 upstream.
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@vger.kernel.org
Cc: Saravana Kannan <saravanak@google.com>
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
---
drivers/base/dd.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a7bcbb99e820..0f006cad2be7 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -785,8 +785,12 @@ static int __driver_attach(struct device *dev, void *data)
*/
return 0;
} else if (ret < 0) {
- dev_dbg(dev, "Bus failed to match device: %d", ret);
- return ret;
+ dev_dbg(dev, "Bus failed to match device: %d\n", ret);
+ /*
+ * Driver could not match with device, but may match with
+ * another device on the bus.
+ */
+ return 0;
} /* ret > 0 means positive match */
if (dev->parent) /* Needed for USB */
--
2.39.0.314.g84b9a713c41-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH stable-4.14] driver core: Fix bus_type.match() error handling in __driver_attach()
2023-01-10 2:15 [PATCH stable-4.14] driver core: Fix bus_type.match() error handling in __driver_attach() Isaac J. Manjarres
@ 2023-01-12 12:52 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-12 12:52 UTC (permalink / raw)
To: Isaac J. Manjarres
Cc: Rafael J. Wysocki, Marek Szyprowski, Tomeu Vizoso, Russell King,
Ulf Hansson, stable, Saravana Kannan, kernel-team, linux-kernel
On Mon, Jan 09, 2023 at 06:15:36PM -0800, Isaac J. Manjarres wrote:
> commit 27c0d217340e47ec995557f61423ef415afba987 upstream.
>
> 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@vger.kernel.org
> Cc: Saravana Kannan <saravanak@google.com>
> Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
> ---
> drivers/base/dd.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
All now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-12 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-10 2:15 [PATCH stable-4.14] driver core: Fix bus_type.match() error handling in __driver_attach() Isaac J. Manjarres
2023-01-12 12:52 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).