@@ -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);