Merge tag 'char-misc-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[linux-block.git] / drivers / bus / fsl-mc / fsl-mc-bus.c
index 0c8bf020ba43ef95a45e5b4df463df1fc5ca6500..380ad1fdb74564b4f63a0150672d5d20afc5b045 100644 (file)
@@ -942,6 +942,15 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev)
        endpoint_desc.id = endpoint2.id;
        endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev);
 
+       /*
+        * We know that the device has an endpoint because we verified by
+        * interrogating the firmware. This is the case when the device was not
+        * yet discovered by the fsl-mc bus, thus the lookup returned NULL.
+        * Differentiate this case by returning EPROBE_DEFER.
+        */
+       if (!endpoint)
+               return ERR_PTR(-EPROBE_DEFER);
+
        return endpoint;
 }
 EXPORT_SYMBOL_GPL(fsl_mc_get_endpoint);