From: Zijun Hu quic_zijuhu@quicinc.com
An uninitialized variable @data.have_async may be used as analyzed by the following inline comments:
static int __device_attach(struct device *dev, bool allow_async) { // if @allow_async is true.
... struct device_attach_data data = { .dev = dev, .check_async = allow_async, .want_async = false, }; // @data.have_async is not initialized.
... ret = bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver); // @data.have_async must not be set by __device_attach_driver() if // @dev->bus does not have driver which allows probe asynchronously
if (!ret && allow_async && data.have_async) { // Above @data.have_async is not uninitialized but used. ... } ... }
It may be unnecessary to trigger the second pass probing asynchronous drivers for the device @dev.
Fixed by initializing @data.have_async to false.
Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com --- drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9b745ba54de1..b0c44b0846aa 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1021,6 +1021,7 @@ static int __device_attach(struct device *dev, bool allow_async) .dev = dev, .check_async = allow_async, .want_async = false, + .have_async = false, };
if (dev->parent)
--- base-commit: 87ee9981d1f86ee9b1623a46c7f9e4ac24461fe4 change-id: 20240823-fix_have_async-3a135618d91b
Best regards,