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: 9592269 X-Patchwork-Delegate: agross@codeaurora.org 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 DD94A6042C for ; Sun, 26 Feb 2017 12:35:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3F8B27F9A for ; Sun, 26 Feb 2017 12:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C61BD28479; Sun, 26 Feb 2017 12:35:16 +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=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1837B27F9A for ; Sun, 26 Feb 2017 12:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752104AbdBZMfO (ORCPT ); Sun, 26 Feb 2017 07:35:14 -0500 Received: from smtp10.smtpout.orange.fr ([80.12.242.132]:57966 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752031AbdBZMfO (ORCPT ); Sun, 26 Feb 2017 07:35:14 -0500 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 Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET 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 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 Reviewed-by: wharms@bfs.de --- 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; }