Skip to contentSkip to conversation

drm/drv: propagate errors from drm_modeset_register_all()

PATCH Superseded Dmitry Baryshkov 2 participants 3 messages May 21, 2023 – Oct 6, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/drv: propagate errors from drm_modeset_register_all()

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")
---
 drivers/gpu/drm/drm_drv.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +8 -2
index c6eb8972451a..dc4a496795ee 100644
@@ -938,8 +938,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,
@@ -949,6 +952,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);
Signature · 1 line
2.39.2
#1 lore raw
Quoted 6 lines · Dmitry Baryshkov

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")

Colleagues, gracious ping.

Quoted 32 lines
---
  drivers/gpu/drm/drm_drv.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +8 -2
index c6eb8972451a..dc4a496795ee 100644
@@ -938,8 +938,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,
@@ -949,6 +952,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);
Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Baryshkov
Quoted 29 lines · Dmitry Baryshkov

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")
---
  drivers/gpu/drm/drm_drv.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_drv.c +5 -2
index c6eb8972451a..dc4a496795ee 100644
@@ -938,8 +938,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,

drivers/gpu/drm/drm_drv.c int drm_dev_register(struct drm_device *dev, unsigned long flags) · line 960

Quoted 9 lines
drivers/gpu/drm/drm_drv.c +3 -0
@@ -949,6 +952,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);

Looks sane to report this error: