From patchwork Sun Feb 6 20:31:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 537931 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p17Cu6oG014205 for ; Mon, 7 Feb 2011 12:56:26 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 223549E902 for ; Mon, 7 Feb 2011 04:56:06 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-fx0-f49.google.com (mail-fx0-f49.google.com [209.85.161.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 799679E75E for ; Sun, 6 Feb 2011 12:31:14 -0800 (PST) Received: by fxm19 with SMTP id 19so4337627fxm.36 for ; Sun, 06 Feb 2011 12:31:13 -0800 (PST) Received: by 10.223.83.4 with SMTP id d4mr2787107fal.59.1297024272819; Sun, 06 Feb 2011 12:31:12 -0800 (PST) Received: from s@fomichev.me ([46.138.69.49]) by mx.google.com with ESMTPS id 11sm924904faw.44.2011.02.06.12.31.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 06 Feb 2011 12:31:11 -0800 (PST) Date: Sun, 6 Feb 2011 23:31:04 +0300 From: Stanislav Fomichev To: airlied@linux.ie Subject: [PATCH] drm_crtc: add kmalloc NULL handling Message-ID: <4d4f050f.cb05df0a.4fb8.4e47@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Mon, 07 Feb 2011 04:54:45 -0800 Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 12:56:26 +0000 (UTC) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 654faa8..10485da 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -657,6 +657,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes, struct drm_property *tv_selector; struct drm_property *tv_subconnector; int i; + int err; if (dev->mode_config.tv_select_subconnector_property) return 0; @@ -667,20 +668,39 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes, tv_selector = drm_property_create(dev, DRM_MODE_PROP_ENUM, "select subconnector", ARRAY_SIZE(drm_tv_select_enum_list)); - for (i = 0; i < ARRAY_SIZE(drm_tv_select_enum_list); i++) - drm_property_add_enum(tv_selector, i, - drm_tv_select_enum_list[i].type, - drm_tv_select_enum_list[i].name); + + if (!tv_selector) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(drm_tv_select_enum_list); i++) { + err = drm_property_add_enum(tv_selector, i, + drm_tv_select_enum_list[i].type, + drm_tv_select_enum_list[i].name); + + if (err) + goto destroy_tv_selector; + } + dev->mode_config.tv_select_subconnector_property = tv_selector; tv_subconnector = drm_property_create(dev, DRM_MODE_PROP_ENUM | DRM_MODE_PROP_IMMUTABLE, "subconnector", ARRAY_SIZE(drm_tv_subconnector_enum_list)); - for (i = 0; i < ARRAY_SIZE(drm_tv_subconnector_enum_list); i++) - drm_property_add_enum(tv_subconnector, i, - drm_tv_subconnector_enum_list[i].type, - drm_tv_subconnector_enum_list[i].name); + + if (!tv_subconnector) { + err = -ENOMEM; + goto destroy_tv_selector; + } + + for (i = 0; i < ARRAY_SIZE(drm_tv_subconnector_enum_list); i++) { + err = drm_property_add_enum(tv_subconnector, i, + drm_tv_subconnector_enum_list[i].type, + drm_tv_subconnector_enum_list[i].name); + + if (err) + goto destroy_tv_subconnector; + } dev->mode_config.tv_subconnector_property = tv_subconnector; /* @@ -689,71 +709,184 @@ int drm_mode_create_tv_properties(struct drm_device *dev, int num_modes, dev->mode_config.tv_left_margin_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "left margin", 2); + + if (!dev->mode_config.tv_left_margin_property) { + err = -ENOMEM; + goto destroy_tv_subconnector; + } + dev->mode_config.tv_left_margin_property->values[0] = 0; dev->mode_config.tv_left_margin_property->values[1] = 100; dev->mode_config.tv_right_margin_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "right margin", 2); + + if (!dev->mode_config.tv_right_margin_property) { + err = -ENOMEM; + goto destroy_tv_left_margin; + } dev->mode_config.tv_right_margin_property->values[0] = 0; dev->mode_config.tv_right_margin_property->values[1] = 100; dev->mode_config.tv_top_margin_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "top margin", 2); + + if (!dev->mode_config.tv_top_margin_property) { + err = -ENOMEM; + goto destroy_tv_right_margin; + } + dev->mode_config.tv_top_margin_property->values[0] = 0; dev->mode_config.tv_top_margin_property->values[1] = 100; dev->mode_config.tv_bottom_margin_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "bottom margin", 2); + + if (!dev->mode_config.tv_bottom_margin_property) { + err = -ENOMEM; + goto destroy_tv_top_margin; + } + dev->mode_config.tv_bottom_margin_property->values[0] = 0; dev->mode_config.tv_bottom_margin_property->values[1] = 100; dev->mode_config.tv_mode_property = drm_property_create(dev, DRM_MODE_PROP_ENUM, "mode", num_modes); - for (i = 0; i < num_modes; i++) - drm_property_add_enum(dev->mode_config.tv_mode_property, i, - i, modes[i]); + + if (!dev->mode_config.tv_mode_property) { + err = -ENOMEM; + goto destroy_tv_bottom_margin; + } + + for (i = 0; i < num_modes; i++) { + err = drm_property_add_enum(dev->mode_config.tv_mode_property, + i, i, modes[i]); + + if (err) + goto destroy_tv_mode; + } dev->mode_config.tv_brightness_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "brightness", 2); + + if (!dev->mode_config.tv_brightness_property) { + err = -ENOMEM; + + goto destroy_tv_mode; + } + dev->mode_config.tv_brightness_property->values[0] = 0; dev->mode_config.tv_brightness_property->values[1] = 100; dev->mode_config.tv_contrast_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "contrast", 2); + + if (!dev->mode_config.tv_contrast_property) { + err = -ENOMEM; + + goto destroy_tv_brightness; + } + dev->mode_config.tv_contrast_property->values[0] = 0; dev->mode_config.tv_contrast_property->values[1] = 100; dev->mode_config.tv_flicker_reduction_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "flicker reduction", 2); + + if (!dev->mode_config.tv_flicker_reduction_property) { + err = -ENOMEM; + + goto destroy_tv_contrast; + } + dev->mode_config.tv_flicker_reduction_property->values[0] = 0; dev->mode_config.tv_flicker_reduction_property->values[1] = 100; dev->mode_config.tv_overscan_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "overscan", 2); + + if (!dev->mode_config.tv_overscan_property) { + err = -ENOMEM; + + goto destroy_tv_flicker_reduction; + } + dev->mode_config.tv_overscan_property->values[0] = 0; dev->mode_config.tv_overscan_property->values[1] = 100; dev->mode_config.tv_saturation_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "saturation", 2); + + if (!dev->mode_config.tv_saturation_property) { + err = -ENOMEM; + + goto destroy_tv_overscan; + } + dev->mode_config.tv_saturation_property->values[0] = 0; dev->mode_config.tv_saturation_property->values[1] = 100; dev->mode_config.tv_hue_property = drm_property_create(dev, DRM_MODE_PROP_RANGE, "hue", 2); + + if (!dev->mode_config.tv_hue_property) { + err = -ENOMEM; + + goto destroy_tv_saturation; + } + dev->mode_config.tv_hue_property->values[0] = 0; dev->mode_config.tv_hue_property->values[1] = 100; return 0; + +destroy_tv_saturation: + drm_property_destroy(dev, dev->mode_config.tv_saturation_property); + +destroy_tv_overscan: + drm_property_destroy(dev, dev->mode_config.tv_overscan_property); + +destroy_tv_flicker_reduction: + drm_property_destroy(dev, dev->mode_config.tv_flicker_reduction_property); + +destroy_tv_contrast: + drm_property_destroy(dev, dev->mode_config.tv_contrast_property); + +destroy_tv_brightness: + drm_property_destroy(dev, dev->mode_config.tv_brightness_property); + +destroy_tv_mode: + drm_property_destroy(dev, dev->mode_config.tv_mode_property); + +destroy_tv_bottom_margin: + drm_property_destroy(dev, dev->mode_config.tv_bottom_margin_property); + +destroy_tv_top_margin: + drm_property_destroy(dev, dev->mode_config.tv_top_margin_property); + +destroy_tv_right_margin: + drm_property_destroy(dev, dev->mode_config.tv_right_margin_property); + +destroy_tv_left_margin: + drm_property_destroy(dev, dev->mode_config.tv_left_margin_property); + +destroy_tv_subconnector: + drm_property_destroy(dev, tv_subconnector); + +destroy_tv_selector: + drm_property_destroy(dev, tv_selector); + + return err; } EXPORT_SYMBOL(drm_mode_create_tv_properties); @@ -2375,6 +2508,9 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, connector->edid_blob_ptr = drm_property_create_blob(connector->dev, size, edid); + if (!connector->edid_blob_ptr) + return -ENOMEM; + ret = drm_connector_property_set_value(connector, dev->mode_config.edid_property, connector->edid_blob_ptr->base.id);