From patchwork Tue Sep 18 10:21:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11496 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B449D23EFC for ; Tue, 18 Sep 2012 10:24:53 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id EFCC4A18FC6 for ; Tue, 18 Sep 2012 10:24:52 +0000 (UTC) Received: by iafj25 with SMTP id j25so5814456iaf.11 for ; Tue, 18 Sep 2012 03:24:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=Tsbvuu2PVmg2ZlwQSVbjpmKXOhVlMCot/zmLZ+bC7nw=; b=PMdj4BqDPJ7H5WFO1ZWPro95eOOMEag7DGQNUSTGmwjYXX15Zc1q9GRxq4gUx4uKlF E0fQDVap/EpLZwbPOQjcCXBrvBzNLyNsZXs9uL3yr9Orsl7nGvX5fBKCRHiXZUT8KPlg FXLGxwndDtN3yDG81Msoc/WG1mrkkDQdYxVyG8N5IETydi9PTtPi0Dfj1m4sAdmIlgRX 8/57qoab4WaVGTcVY1r30zjfDqPfEDZ2e3X0tnzBdefxaVhBiIGFX1pMQ/j0IgTGcR4F KcUeg7KEHOzLioLn8+cYV5H9FFSi65VM3sFMsiLvpPcVi5fvTrKRbDywS9yC6CdEsf3i 7xWQ== Received: by 10.42.60.139 with SMTP id q11mr11402567ich.53.1347963892234; Tue, 18 Sep 2012 03:24:52 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp365846igc; Tue, 18 Sep 2012 03:24:50 -0700 (PDT) Received: by 10.68.226.132 with SMTP id rs4mr504934pbc.75.1347963890625; Tue, 18 Sep 2012 03:24:50 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id z10si259353pay.347.2012.09.18.03.24.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Sep 2012 03:24:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by pbcmd12 with SMTP id md12so12351731pbc.37 for ; Tue, 18 Sep 2012 03:24:50 -0700 (PDT) Received: by 10.68.203.200 with SMTP id ks8mr364377pbc.142.1347963890157; Tue, 18 Sep 2012 03:24:50 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id py9sm8437898pbb.20.2012.09.18.03.24.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Sep 2012 03:24:49 -0700 (PDT) From: Sachin Kamat To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, airlied@linux.ie, sachin.kamat@linaro.org, patches@linaro.org, jy0922.shim@samsung.com, sw0312.kim@samsung.com Subject: [PATCH] drm/exynos: Fix potential NULL pointer dereference Date: Tue, 18 Sep 2012 15:51:30 +0530 Message-Id: <1347963690-4998-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQk+v4kIvFp8ZHmlN932JG15Z2dEwf6Bffe3V+VHOVXeTRTs6TEUsbWtlOEycqG1hQna8aTI drm_mode_create() returns NULL if it fails to create a new display mode. Check the value returned to avoid NULL pointer deferencing later. Signed-off-by: Sachin Kamat --- drivers/gpu/drm/exynos/exynos_drm_connector.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c index 9dce3b9..485e984 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_connector.c +++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c @@ -149,8 +149,12 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector) count = drm_add_edid_modes(connector, edid); kfree(edid); } else { - struct drm_display_mode *mode = drm_mode_create(connector->dev); struct exynos_drm_panel_info *panel; + struct drm_display_mode *mode = drm_mode_create(connector->dev); + if (!mode) { + DRM_ERROR("failed to create a new display mode.\n"); + return 0; + } if (display_ops->get_panel) panel = display_ops->get_panel(manager->dev);