From patchwork Mon Jul 27 12:06:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6872761 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D37719F380 for ; Mon, 27 Jul 2015 12:06:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0282B2068A for ; Mon, 27 Jul 2015 12:06:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 17A3620684 for ; Mon, 27 Jul 2015 12:06:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61F626E4D5; Mon, 27 Jul 2015 05:06:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8848D6E778; Mon, 27 Jul 2015 05:06:31 -0700 (PDT) Received: by pdjr16 with SMTP id r16so52091787pdj.3; Mon, 27 Jul 2015 05:06:31 -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=kos9nqtrgon0YGUEFkz1BgW8beEwvJKNOG7OUXarI1Q=; b=lDQFif8ZuW/t6BXHVnHLzBWd/m5+k349nts5Hcay+LJrzqD1BpOcT06MFy3W035cD3 mYK37NpVFtrfa0QjMqQKN/MYdVdhfBg/Op894i5qvZdEe4V86VGpfw4bNaUYPn3K5WhM foRR5RRL7mFJy3Yy5fqMBS5MqVkqNneeqSIY+VvsAE7XB+nIzk2+2A+2Vaa5YKJphLEx oN2zcVlB45qIg2BRW35sakHpzrB5RWuJhARrXTNkTRqF5xC7Abn0/v1+aWHrL+7AKCE4 uR9RUtLKz0kJ8Ae7Zqf2SQrjsHQEvuVJUrdbodwC7iMofIyXUJ5ci1GzxMsywDJiaiR+ PG1w== X-Received: by 10.70.56.4 with SMTP id w4mr68520446pdp.148.1437998790662; Mon, 27 Jul 2015 05:06:30 -0700 (PDT) Received: from localhost.localdomain ([49.206.240.169]) by smtp.gmail.com with ESMTPSA id g10sm29377869pat.35.2015.07.27.05.06.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Jul 2015 05:06:30 -0700 (PDT) From: Sudip Mukherjee To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH 2/2] drm/i915: check for return value Date: Mon, 27 Jul 2015 17:36:16 +0530 Message-Id: <1437998776-4064-2-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1437998776-4064-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1437998776-4064-1-git-send-email-sudipm.mukherjee@gmail.com> Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, 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=-5.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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. Signed-off-by: Sudip Mukherjee --- 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 c084bca..69946b7 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -5870,8 +5870,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; @@ -5919,6 +5920,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);