drm/drv: propagate errors from drm_modeset_register_all()
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sat, 2 Dec 2023 22:55:52 +0000 (01:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:33 +0000 (15:35 -0800)
[ Upstream commit 5f8dec200923a76dc57187965fd59c1136f5d085 ]

In case the drm_modeset_register_all() function fails, its error code
will be ignored. Instead make the drm_dev_register() bail out in case of
such an error.

Fixes: 79190ea2658a ("drm: Add callbacks for late registering")
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231202225552.1283638-1-dmitry.baryshkov@linaro.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/drm_drv.c

index 3eda026..71bb880 100644 (file)
@@ -940,8 +940,11 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
                        goto err_minors;
        }
 
-       if (drm_core_check_feature(dev, DRIVER_MODESET))
-               drm_modeset_register_all(dev);
+       if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+               ret = drm_modeset_register_all(dev);
+               if (ret)
+                       goto err_unload;
+       }
 
        DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n",
                 driver->name, driver->major, driver->minor,
@@ -951,6 +954,9 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 
        goto out_unlock;
 
+err_unload:
+       if (dev->driver->unload)
+               dev->driver->unload(dev);
 err_minors:
        remove_compat_control_link(dev);
        drm_minor_unregister(dev, DRM_MINOR_ACCEL);