From patchwork Fri Jun 13 19:51:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Jaeger X-Patchwork-Id: 4355641 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BE66C9F333 for ; Mon, 16 Jun 2014 00:54:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8E722024F for ; Mon, 16 Jun 2014 00:54:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C344820221 for ; Mon, 16 Jun 2014 00:54:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9E276E2C0; Sun, 15 Jun 2014 17:54:51 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 365 seconds by postgrey-1.34 at gabe; Fri, 13 Jun 2014 12:57:39 PDT Received: from smtprelay05.ispgateway.de (smtprelay05.ispgateway.de [80.67.31.100]) by gabe.freedesktop.org (Postfix) with ESMTP id E91786EAE4; Fri, 13 Jun 2014 12:57:39 -0700 (PDT) Received: from [92.224.223.255] (helo=betelgeuse.mikrowelle.local) by smtprelay05.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1WvXVX-0000P2-7d; Fri, 13 Jun 2014 21:51:27 +0200 From: Christoph Jaeger To: daniel.vetter@ffwll.ch, jani.nikula@linux.intel.com, airlied@linux.ie Subject: [PATCH] drm/i915: Fix memory leak in intel_dsi_init() error path Date: Fri, 13 Jun 2014 21:51:22 +0200 Message-Id: <1402689082-20211-1-git-send-email-christophjaeger@linux.com> X-Mailer: git-send-email 1.9.3 X-Df-Sender: MTg4NDM4Mw== X-Mailman-Approved-At: Sun, 15 Jun 2014 17:54:49 -0700 Cc: intel-gfx@lists.freedesktop.org, Christoph Jaeger , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 intel_dsi_init() bails out without freeing the memory 'intel_dsi' and 'intel_connector' point to. Simply bail out before allocating memory. Picked up by Coverity - CID 1222750. Signed-off-by: Christoph Jaeger --- drivers/gpu/drm/i915/intel_dsi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 02f99d7..6965627 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -675,6 +675,13 @@ bool intel_dsi_init(struct drm_device *dev) if (!dev_priv->vbt.has_mipi) return false; + if (IS_VALLEYVIEW(dev)) { + dev_priv->mipi_mmio_base = VLV_MIPI_BASE; + } else { + DRM_ERROR("Unsupported Mipi device to reg base"); + return false; + } + intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL); if (!intel_dsi) return false; @@ -689,13 +696,6 @@ bool intel_dsi_init(struct drm_device *dev) encoder = &intel_encoder->base; intel_dsi->attached_connector = intel_connector; - if (IS_VALLEYVIEW(dev)) { - dev_priv->mipi_mmio_base = VLV_MIPI_BASE; - } else { - DRM_ERROR("Unsupported Mipi device to reg base"); - return false; - } - connector = &intel_connector->base; drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);