From patchwork Sun Feb 26 12:10:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9592707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7AE78604AB for ; Mon, 27 Feb 2017 05:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D52A27FB1 for ; Mon, 27 Feb 2017 05:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6225928375; Mon, 27 Feb 2017 05:15:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D23EC27FB1 for ; Mon, 27 Feb 2017 05:15:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E8626E1A0; Mon, 27 Feb 2017 05:14:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.smtpout.orange.fr (smtp10.smtpout.orange.fr [80.12.242.132]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E8356E286 for ; Sun, 26 Feb 2017 12:26:42 +0000 (UTC) Received: from localhost.localdomain ([92.140.162.61]) by mwinf5d19 with ME id pQSc1u00a1KnKiL03QScYd; Sun, 26 Feb 2017 13:26:41 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 26 Feb 2017 13:26:41 +0100 X-ME-IP: 92.140.162.61 From: Christophe JAILLET To: robdclark@gmail.com, airlied@linux.ie, architt@codeaurora.org, hali@codeaurora.org, yongjun_wei@trendmicro.com.cn Subject: [PATCH v2] drm/msm/dsi: Fix the releasing of resources in error path in 'dsi_bus_clk_enable()' Date: Sun, 26 Feb 2017 13:10:57 +0100 Message-Id: <20170226121057.9717-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.9.3 X-Antivirus: avast! (VPS 170226-0, 26/02/2017), Outbound message X-Antivirus-Status: Clean X-Mailman-Approved-At: Mon, 27 Feb 2017 01:45:06 +0000 Cc: linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Christophe JAILLET , freedreno@lists.freedesktop.org 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-Virus-Scanned: ClamAV using ClamSMTP If a 'clk_prepare_enable()' fails, then we need to disable_unprepare the clk already handled. With the current implemenatation, we try to do that on the clk that has triggered the error, which is a no-op and leave msm_host->bus_clks[0] untouched. Count forward in order to fix it and be more future proof. Signed-off-by: Christophe JAILLET --- v2: change the for loop from a backward to a forward one, to ease reading. --- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 1fc07ce24686..e6f56cd8ce08 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -422,7 +422,7 @@ static int dsi_clk_init(struct msm_dsi_host *msm_host) static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host) { const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg; - int i, ret; + int i, j, ret; DBG("id=%d", msm_host->id); @@ -437,8 +437,8 @@ static int dsi_bus_clk_enable(struct msm_dsi_host *msm_host) return 0; err: - for (; i > 0; i--) - clk_disable_unprepare(msm_host->bus_clks[i]); + for (j = 0; j < i; j++) + clk_disable_unprepare(msm_host->bus_clks[j]); return ret; }