From patchwork Wed Dec 5 19:00:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1844121 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 046623FC71 for ; Thu, 6 Dec 2012 09:20:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F19FE6688 for ; Thu, 6 Dec 2012 01:20:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 1931 seconds by postgrey-1.32 at gabe; Wed, 05 Dec 2012 11:32:25 PST Received: from mail.tpi.com (mail.tpi.com [70.99.223.143]) by gabe.freedesktop.org (Postfix) with ESMTP id DBF60E5C33 for ; Wed, 5 Dec 2012 11:32:25 -0800 (PST) Received: from salmon.rtg.net (mail.tpi.com [70.99.223.143]) by mail.tpi.com (Postfix) with ESMTP id DEC4032EECB; Wed, 5 Dec 2012 11:00:08 -0800 (PST) Received: by salmon.rtg.net (Postfix, from userid 1000) id 97BF1217B2; Wed, 5 Dec 2012 12:00:08 -0700 (MST) From: Tim Gardner To: linux-kernel@vger.kernel.org Subject: [PATCH 3.7-rc8] drm: Fix possible EDID memory allocation oops Date: Wed, 5 Dec 2012 12:00:03 -0700 Message-Id: <1354734003-92714-1-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 1.7.9.5 X-Mailman-Approved-At: Thu, 06 Dec 2012 00:43:17 -0800 Cc: Tim Gardner , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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 The result of drm_property_create_blob() is not checked for success which could lead to a NULL pointer dereference. I was led to this by a smatch warning: drivers/gpu/drm/drm_crtc.c:3186 drm_mode_connector_update_edid_property() error: potential null dereference 'connector->edid_blob_ptr'. (drm_property_create_blob returns null) drm_property_create_blob() calls kzalloc() which can return NULL. Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: stable@vger.kernel.org # 3.0+ Signed-off-by: Tim Gardner Reviewed-by: Alex Deucher --- This bug actually exists in the original commit f453ba0460742ad027ae0c4c7d61e62817b3e7ef (2.6.29), but I only checked as far back as 3.0 for stable. drivers/gpu/drm/drm_crtc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index ef1b221..31872ba 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -3180,6 +3180,10 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector, size = EDID_LENGTH * (1 + edid->extensions); connector->edid_blob_ptr = drm_property_create_blob(connector->dev, size, edid); + if (!connector->edid_blob_ptr) { + pr_err("drm: Could not allocate %d edid blob bytes.\n", size); + return -ENOMEM; + } ret = drm_connector_property_set_value(connector, dev->mode_config.edid_property,