From patchwork Thu Oct 8 13:58:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7352991 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0D4CBEEA4 for ; Thu, 8 Oct 2015 13:58:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 174E020818 for ; Thu, 8 Oct 2015 13:58:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EEE5720810 for ; Thu, 8 Oct 2015 13:58:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D21B16ECE5; Thu, 8 Oct 2015 06:58:14 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D62F6ECE4; Thu, 8 Oct 2015 06:58:13 -0700 (PDT) Received: by pablk4 with SMTP id lk4so55907042pab.3; Thu, 08 Oct 2015 06:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wwSkjmu4taPD4Dd0inzH0ZDnAxWFsUjbQAZSvnZRGn0=; b=n/D1V0n3CyA4xSRByH0f/+zGvlzpu+u3WQpvk15JJvM7JXCEeChISFUjjVn3Bkcnaf vCLGr+VUwAn545MhMJvFOiwK7/MBGR1dSxATjhYtABiOszlPd0Lu/KAzK841lLRmQpfg xlGiWaapTjZCl2RiVer6IEBsNR4g08YbnjlI2SrZL2vktMigEz/2ioj+IoTBZ4UOyZY4 FEadnbMnv/Xn30Rt4XxDU+63aCi7WGbb0qd8ogD5Bdc9yDWZoG1T1TFXvn41BONLPKOG xBZ2dIjZRcOSh11vj24rFN1rFkKSnRbeGRLj11XvAlRpY4CfKF93BqASOabZ91nI57Oe 2rag== X-Received: by 10.68.68.205 with SMTP id y13mr8347679pbt.73.1444312693035; Thu, 08 Oct 2015 06:58:13 -0700 (PDT) Received: from localhost.localdomain ([49.206.251.3]) by smtp.gmail.com with ESMTPSA id qp5sm45740820pbc.43.2015.10.08.06.58.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 06:58:12 -0700 (PDT) From: Sudip Mukherjee To: David Airlie , Daniel Vetter Subject: [PATCH RESEND 2/3] drm/i915: check for return value Date: Thu, 8 Oct 2015 19:28:00 +0530 Message-Id: <1444312681-10149-2-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444312681-10149-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1444312681-10149-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Daniel Vetter , Sudip Mukherjee X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We were not checking the return value of drm_encoder_init() which can fail. And if it fails then we will be working with an uninitialized encoder. Cc: Daniel Vetter Cc: Jani Nikula Signed-off-by: Sudip Mukherjee --- Sent on 27/07/2015 drivers/gpu/drm/i915/intel_dp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 18bcfbe..2a8b47e 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -6174,8 +6174,9 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) intel_encoder = &intel_dig_port->base; encoder = &intel_encoder->base; - drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs, - DRM_MODE_ENCODER_TMDS); + if (drm_encoder_init(dev, &intel_encoder->base, &intel_dp_enc_funcs, + DRM_MODE_ENCODER_TMDS)) + goto err_encoder_init; intel_encoder->compute_config = intel_dp_compute_config; intel_encoder->disable = intel_disable_dp; @@ -6224,6 +6225,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) err_init_connector: drm_encoder_cleanup(encoder); +err_encoder_init: kfree(intel_connector); err_connector_alloc: kfree(intel_dig_port);