From patchwork Sat Feb 18 13:19:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9581085 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 1164E604A4 for ; Sat, 18 Feb 2017 13:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02E00283CA for ; Sat, 18 Feb 2017 13:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBDA12846A; Sat, 18 Feb 2017 13:27:20 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 9923E283CA for ; Sat, 18 Feb 2017 13:27:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088AbdBRN1S (ORCPT ); Sat, 18 Feb 2017 08:27:18 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35778 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752824AbdBRN1O (ORCPT ); Sat, 18 Feb 2017 08:27:14 -0500 Received: by mail-wm0-f66.google.com with SMTP id u63so6839445wmu.2 for ; Sat, 18 Feb 2017 05:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=DKaHBB5bI6uGQNlN/eT4ej+TR69lZkICob+L/9+J5DQ=; b=kB1ERD11/n57KWnWMniU+A/sYcwlknyodNNJ+NpZ4BLWmxe8Rv0/p12g27W6hDsPr3 kWN5gMUGF/yPaCFrR1wMh3aEt1mBAKgjzFl9hXl/+QaSj8lFRY08YrpA427W5zJmAm5/ yM53KZ1PzOtYNp9/SBbu1D8lU4XRG62SGZGobak78o9OildotAFmkozGlSYwW5R7ULX1 0xvSpM3braP2t/HSf4eSkP/3avr/aIYuuUe6WfXepS8+FRss+Bx+4PS/VwrITTyJFk9j pvCwe0SKVbWLy2D3iI7q6Si+JcShe5w1cWOYvLvdY17uQcr4q7bzMqQ8m25lOrTgwJYk 0/+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=DKaHBB5bI6uGQNlN/eT4ej+TR69lZkICob+L/9+J5DQ=; b=D7EUx7bZfCzh19Q2mPvFFHLPEN97y3PX7DnOUZ4vSn5XGVkMWbRRgguQ7VYvwydZRE WSajPmJ3VrKIEfJ46VUNe1UszA/Wx+G4QZLX0F/mx7N9OnH4FwvJdemdXqSbQ3Btm0B2 J/CI1kWySGo+Op0f3MK4XGc3nlepDOd82YGpnK3SzwozyXsB1anFm/lQKnpiEhbtJyxy GKOy6XTBKKKgm3qTm+hdepRfJ/lW4uoGEeOWDCfY4JvTO98GNtcZfBVu0Gg25E9w8P0R deaWHJaJQEE0t+iOavxcFlBWgYvK58Bv7xDJVCAdJ4F67pOA2zgNIZ5GSOIa6y40t0A9 yhKA== X-Gm-Message-State: AMke39ngc/jhH7ZPQaTUqhJ/7SPHXBzGOq0leMeVU34w4balk24TXoY1DwbH7fBv9HQBRw== X-Received: by 10.28.49.70 with SMTP id x67mr9365536wmx.69.1487424399226; Sat, 18 Feb 2017 05:26:39 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:7c19:f774:dabe:f95d? (p200300C6EBDC40007C19F774DABEF95D.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:7c19:f774:dabe:f95d]) by smtp.googlemail.com with ESMTPSA id r19sm16904214wrr.44.2017.02.18.05.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 05:26:38 -0800 (PST) Subject: [PATCH v3 6/10] mmc: meson-gx: fix error path in meson_mmc_clk_init / meson_mmc_probe To: Ulf Hansson , Kevin Hilman References: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> Cc: "linux-mmc@vger.kernel.org" , linux-amlogic@lists.infradead.org, =?UTF-8?Q?Micha=c5=82_Zegan?= From: Heiner Kallweit Message-ID: <8419d592-1338-d7eb-3a75-342b64897922@gmail.com> Date: Sat, 18 Feb 2017 14:19:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The condition should be "if (ret)" as the disable/unprepare is supposed to be executed if the previous command fails. In addition adjust the error path in probe to properly deal with the case that cfg_div_clk can be registered successfully but enable/prepare fails. In this case we shouldn't call clk_disable_unprepare. Reported-by: Michał Zegan Signed-off-by: Heiner Kallweit Reviewed-by: Michał Zegan Acked-by: Kevin Hilman --- v2: - extended commit message v3: - adjust error path in probe --- drivers/mmc/host/meson-gx-mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 68e76fa8..002e4aac 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -321,7 +321,7 @@ static int meson_mmc_clk_init(struct meson_host *host) host->mmc->f_min = clk_round_rate(host->cfg_div_clk, 400000); ret = meson_mmc_clk_set(host, host->mmc->f_min); - if (!ret) + if (ret) clk_disable_unprepare(host->cfg_div_clk); return ret; @@ -771,7 +771,7 @@ static int meson_mmc_probe(struct platform_device *pdev) meson_mmc_irq_thread, IRQF_SHARED, DRIVER_NAME, host); if (ret) - goto free_host; + goto err_div_clk; mmc->max_blk_count = CMD_CFG_LENGTH_MASK; mmc->max_req_size = mmc->max_blk_count * mmc->max_blk_size; @@ -784,7 +784,7 @@ static int meson_mmc_probe(struct platform_device *pdev) if (host->bounce_buf == NULL) { dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); ret = -ENOMEM; - goto free_host; + goto err_div_clk; } mmc->ops = &meson_mmc_ops; @@ -792,8 +792,9 @@ static int meson_mmc_probe(struct platform_device *pdev) return 0; -free_host: +err_div_clk: clk_disable_unprepare(host->cfg_div_clk); +free_host: clk_disable_unprepare(host->core_clk); mmc_free_host(mmc); return ret;