summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2026-01-26 14:12:02 +0100
committerDanilo Krummrich <dakr@kernel.org>2026-01-26 14:12:02 +0100
commit559ac491542c00e2389f8cfc49661527b3b0d8a0 (patch)
treeb3d232bc43883f63b9109da75639e6271bfbd847 /drivers/base
parenteb3dad518e4da48ab6c6df16aa8895b8b0bd6ecf (diff)
parented1ac3c977dd6b119405fa36dd41f7151bd5b4de (diff)
Merge tag 'driver-core-6.19-rc7-deferred' into driver-core-next
Driver core fixes deferred from 6.19-rc7 [1, 2] were originally intended for -rc7. Patch [1] uncovered potential deadlocks that require a few driver fixes; [2] is one such fix. [1] https://patch.msgid.link/20260113162843.12712-1-hanguidong02@gmail.com [2] https://patch.msgid.link/20260121141215.29658-1-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/base.h9
-rw-r--r--drivers/base/bus.c2
-rw-r--r--drivers/base/dd.c2
3 files changed, 11 insertions, 2 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 60ee4d466b29..5bc1439d3498 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -182,9 +182,18 @@ void device_set_deferred_probe_reason(const struct device *dev, struct va_format
static inline int driver_match_device(const struct device_driver *drv,
struct device *dev)
{
+ device_lock_assert(dev);
+
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
}
+static inline int driver_match_device_locked(const struct device_driver *drv,
+ struct device *dev)
+{
+ guard(device)(dev);
+ return driver_match_device(drv, dev);
+}
+
static inline void dev_sync_state(struct device *dev)
{
if (dev->bus->sync_state)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 9eb7771706f0..331d750465e2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -263,7 +263,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
int err = -ENODEV;
dev = bus_find_device_by_name(bus, NULL, buf);
- if (dev && driver_match_device(drv, dev)) {
+ if (dev && driver_match_device_locked(drv, dev)) {
err = device_driver_attach(drv, dev);
if (!err) {
/* success */
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index bea8da5f8a3a..ed3a07624816 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1180,7 +1180,7 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/
- ret = driver_match_device(drv, dev);
+ ret = driver_match_device_locked(drv, dev);
if (ret == 0) {
/* no match */
return 0;