]> git.baikalelectronics.ru Git - kernel.git/commitdiff
driver core: Fix bus_type.match() error handling in __driver_attach()
authorIsaac J. Manjarres <isaacmanjarres@google.com>
Wed, 21 Sep 2022 00:14:13 +0000 (17:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:42:00 +0000 (11:42 +0100)
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: 4b362344f9e8 ("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>
Link: https://lore.kernel.org/r/20220921001414.4046492-1-isaacmanjarres@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/dd.c

index 10063d8a1b7d4a812543db2a703191e0a0d0d078..1abd39ed3f9f39d4b6398db2e23f247a97dfec43 100644 (file)
@@ -1068,8 +1068,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 (driver_allows_async_probing(drv)) {