diff mbox

[21/37] drm: Propagate failure from drm_setup_crtcs()

Message ID 1268261124-13653-22-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State Not Applicable
Headers show

Commit Message

Chris Wilson March 10, 2010, 10:45 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index b3f369f..6b2cd91 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -494,7 +494,7 @@  out:
 	return best_score;
 }
 
-static void drm_setup_crtcs(struct drm_device *dev)
+static int drm_setup_crtcs(struct drm_device *dev)
 {
 	struct drm_crtc **crtcs;
 	struct drm_display_mode **modes;
@@ -520,6 +520,12 @@  static void drm_setup_crtcs(struct drm_device *dev)
 			sizeof(struct drm_display_mode *), GFP_KERNEL);
 	enabled = kcalloc(dev->mode_config.num_connector,
 			  sizeof(bool), GFP_KERNEL);
+	if (crtcs == NULL || modes == NULL || enabled == NULL) {
+		kfree(crtcs);
+		kfree(modes);
+		kfree(enabled);
+		return -ENOMEM;
+	}
 
 	drm_enable_connectors(dev, enabled);
 
@@ -556,6 +562,8 @@  static void drm_setup_crtcs(struct drm_device *dev)
 	kfree(crtcs);
 	kfree(modes);
 	kfree(enabled);
+
+	return 0;
 }
 
 /**
@@ -1018,6 +1026,7 @@  bool drm_helper_plugged_event(struct drm_device *dev)
 bool drm_helper_initial_config(struct drm_device *dev)
 {
 	int count = 0;
+	int ret;
 
 	/* disable all the possible outputs/crtcs before entering KMS mode */
 	drm_helper_disable_unused_functions(dev);
@@ -1034,7 +1043,9 @@  bool drm_helper_initial_config(struct drm_device *dev)
 	if (count == 0)
 		printk(KERN_INFO "No connectors reported connected with modes\n");
 
-	drm_setup_crtcs(dev);
+	ret = drm_setup_crtcs(dev);
+	if (ret)
+		return ret;
 
 	/* alert the driver fb layer */
 	dev->mode_config.funcs->fb_changed(dev);