Skip to content

Commit b292b50

Browse files
Tetsuo Handagregkh
authored andcommitted
driver core: Fix probe_count imbalance in really_probe()
syzbot is reporting hung task in wait_for_device_probe() [1]. At least, we always need to decrement probe_count if we incremented probe_count in really_probe(). However, since I can't find "Resources present before probing" message in the console log, both "this message simply flowed off" and "syzbot is not hitting this path" will be possible. Therefore, while we are at it, let's also prepare for concurrent wait_for_device_probe() calls by replacing wake_up() with wake_up_all(). [1] https://syzkaller.appspot.com/bug?id=25c833f1983c9c1d512f4ff860dd0d7f5a2e2c0f Reported-by: syzbot <[email protected]> Fixes: 7c35e69 ("driver core: Print device when resources present in really_probe()") Cc: Geert Uytterhoeven <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bf9b82b commit b292b50

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/base/dd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work)
276276

277277
list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe)
278278
dev_info(private->device, "deferred probe pending\n");
279-
wake_up(&probe_timeout_waitqueue);
279+
wake_up_all(&probe_timeout_waitqueue);
280280
}
281281
static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
282282

@@ -498,7 +498,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
498498
drv->bus->name, __func__, drv->name, dev_name(dev));
499499
if (!list_empty(&dev->devres_head)) {
500500
dev_crit(dev, "Resources present before probing\n");
501-
return -EBUSY;
501+
ret = -EBUSY;
502+
goto done;
502503
}
503504

504505
re_probe:
@@ -627,7 +628,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
627628
ret = 0;
628629
done:
629630
atomic_dec(&probe_count);
630-
wake_up(&probe_waitqueue);
631+
wake_up_all(&probe_waitqueue);
631632
return ret;
632633
}
633634

0 commit comments

Comments
 (0)