Re: [PATCH] driver core: take parent lock on deferred probe
From: Danilo Krummrich
Date: Tue Oct 13 2026 - 14:36:41 EST
On Tue Oct 13, 2026 at 4:06 PM CEST, Johan Hovold wrote:
> +void bus_probe_device_deferred(struct device *dev)
> +{
> + if (dev->parent && dev->bus->need_parent_lock)
> + device_lock(dev->parent);
This looks like it has the same potential UAF as the other patch. It's quite
unfortunate we need the whole need_parent_lock thing just for USB. IIUC the
main reason USB needs this is because interface devices share resources of USB
devices and we need to keep the locking order to avoid inversions, right? Is
there more to this from the USB side of things?
I think we can probably do something like this
struct device *parent = NULL;
scoped_guard(device, dev) {
if (dev->p->dead)
return;
if (dev->bus->need_parent_lock)
parent = get_device(dev->parent);
}
to avoid the problem, but it's still a bit ugly.
> + __bus_probe_device(dev);
> + if (dev->parent && dev->bus->need_parent_lock)
> + device_unlock(dev->parent);
> +}