Re: [driver-core PATCH v4 4/6] driver core: Probe devices asynchronously instead of the driver

From: Bart Van Assche
Date: Thu Oct 18 2018 - 16:14:01 EST


On Thu, 2018-10-18 at 12:38 -0700, Alexander Duyck wrote:
+AD4 Basically if somebody loads a driver the dev-+AD4-driver becomes set. If a
+AD4 driver is removed it will clear dev-+AD4-driver and set driver+AF8-data to
+AD4 0/NULL. That is what I am using as a mutex to track it in conjunction
+AD4 with the device mutex. Basically if somebody attempts to attach a driver
+AD4 before we get there we just exit and don't attempt to load this driver.

I don't think that the above matches your code. +AF8AXw-device+AF8-attach() does not
set the dev-+AD4-driver pointer before scheduling an asynchronous probe. Only
dev-+AD4-driver+AF8-data gets set before the asynchonous probe is scheduled. Since
driver+AF8-detach() only iterates over devices that are in the per-driver klist
it will skip all devices for which an asynchronous probe has been scheduled
but +AF8AXw-device+AF8-attach+AF8-async+AF8-helper() has not yet been called. My conclusion
remains that this patch does not prevent a driver pointer to become invalid
concurrently with +AF8AXw-device+AF8-attach+AF8-async+AF8-helper() dereferencing the same
driver pointer.

Bart.