From patchwork Thu Oct 8 13:57:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7352961 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 E94609F1B9 for ; Thu, 8 Oct 2015 13:58:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2D0020814 for ; Thu, 8 Oct 2015 13:58:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D37F6207FF for ; Thu, 8 Oct 2015 13:58:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14E616ECE2; Thu, 8 Oct 2015 06:58:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id A60506ECE2; Thu, 8 Oct 2015 06:58:10 -0700 (PDT) Received: by pablk4 with SMTP id lk4so55906085pab.3; Thu, 08 Oct 2015 06:58:10 -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; bh=fdY6ILjqObGBmRXrx4SPyOGEXj4/7AFKYKVEwA0AlDY=; b=uImtVB4zSYP5VfFxzsYbCgtaBMH+r1ig+acTTVDANGecpsmmF9Oh/xfMdvDOEzs6WR LPxOcchV/LR8l41GVzyVp+44WlPmWyTtpl3Wc3wNvwtWmNmBsEoBcYdCD3KbFCcBX82w 2Lgphld96tDasVScnEpL6maNofgs1EmWsi35WsPvUpgUAGQgfyOQcKuNbc3DWoUKmD15 jXyzzeBlDTLmFs/dbTpxTfDBWKbyYs90NuxG8TUFKWpdu0Y3MORqvirtrjhKzbRR6B9D fbeqqf5ty0+OfVVuYNeYlHYDA+af1nyT7tqT1+yAiUoc1u+zC4Ef8Dv4k47lqa06fpNG V+XQ== X-Received: by 10.66.102.97 with SMTP id fn1mr8249013pab.97.1444312690129; Thu, 08 Oct 2015 06:58:10 -0700 (PDT) Received: from localhost.localdomain ([49.206.251.3]) by smtp.gmail.com with ESMTPSA id qp5sm45740820pbc.43.2015.10.08.06.58.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 06:58:09 -0700 (PDT) From: Sudip Mukherjee To: David Airlie , Daniel Vetter Subject: [PATCH RESEND 1/3] drm/i915: use error path Date: Thu, 8 Oct 2015 19:27:59 +0530 Message-Id: <1444312681-10149-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 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 Use goto to handle the error path to avoid duplicating the same code. In the error path intel_dig_port is the last one to be released as it was the first one to be allocated and ideally the error path should be the reverse of the execution path. Cc: Daniel Vetter Cc: Jani Nikula Signed-off-by: Sudip Mukherjee --- Sent on 27/07/2015 drivers/gpu/drm/i915/intel_dp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 8d34ca7..18bcfbe 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -6168,10 +6168,8 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) return; intel_connector = intel_connector_alloc(); - if (!intel_connector) { - kfree(intel_dig_port); - return; - } + if (!intel_connector) + goto err_connector_alloc; intel_encoder = &intel_dig_port->base; encoder = &intel_encoder->base; @@ -6219,11 +6217,18 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) intel_dig_port->hpd_pulse = intel_dp_hpd_pulse; dev_priv->hotplug.irq_port[port] = intel_dig_port; - if (!intel_dp_init_connector(intel_dig_port, intel_connector)) { - drm_encoder_cleanup(encoder); - kfree(intel_dig_port); - kfree(intel_connector); - } + if (!intel_dp_init_connector(intel_dig_port, intel_connector)) + goto err_init_connector; + + return; + +err_init_connector: + drm_encoder_cleanup(encoder); + kfree(intel_connector); +err_connector_alloc: + kfree(intel_dig_port); + + return; } void intel_dp_mst_suspend(struct drm_device *dev)