From patchwork Mon Sep 21 21:16:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dewar X-Patchwork-Id: 11791153 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2861859D for ; Mon, 21 Sep 2020 21:21:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E89A72067D for ; Mon, 21 Sep 2020 21:21:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="geOe47H/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sHKrLTGE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E89A72067D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WXVw56XFILvbD736sawhQA7mLeOorppivJ9esfi+1ys=; b=geOe47H/yKSeSAvR7oNN/W+Fi jCHfBWrQtBSz1KqjsLyIyk3sf0uop0+HtNc4yfJdNqNW3DXDqWuk3IlIKDs3qoyxMIfhE/AVhCytV Q7EKVvBGC5/Z51fC9LpjWY5IYqfdiyJ15GAqz9H/h+nsjTRw72r2OF5FlZYR8C3VRhVigR7gcg3Z9 fUQUB6DjeDQMCdhUOsNR+dFwm3nvkCJYIk81xfhhsnqYOwpKWijAPl6j9ScPngc1LodBED3w7P/VD 3Gzodi9mFXHV4u7e6l1/Nysdv9WdLSwhcemKDXFW4wzraD6YBwaVequzVn2ogyq68c07SAPw+cK+H XP4HveGKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKTDc-0001k7-8b; Mon, 21 Sep 2020 21:19:28 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKTDZ-0001jB-2W; Mon, 21 Sep 2020 21:19:26 +0000 Received: by mail-wr1-x443.google.com with SMTP id x14so14393948wrl.12; Mon, 21 Sep 2020 14:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2aErC566HEqSRvdJslRlyUb0c8FokyCT59IKrcXAfu4=; b=sHKrLTGEGIa6Zucq882TmaXZP67AldKWzzzNFviFkhw8wy9dWnOET5rVVOgP0qogAL GhivdlayMQKjNWIJJ3DLRPbYmmZ2/hs9b9bvxElov3PmLJwN+Kw5aBOutZvT/lE6KMNp 9BDI9UpXL9ND+tQiFcy0QoBvDvNUxBGtfOYSt3efw/yK57yR+ZOrYU2UiCLkJbWQviLw msKLopa4Nw4SIF1Q4Hkyd6ljIkubTOvTjKBYYedOWHxI4BuPShjbTOihI4H2keYAjhJH iy9IT9IluUfLE//9SHKtAiPJfnQPqOtOpJT6V7+gYq/9gfhQbeJCaao8JAB2+K0i6BPW IsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2aErC566HEqSRvdJslRlyUb0c8FokyCT59IKrcXAfu4=; b=C0720WXzTzOGJ6vk58cxizATMAZ8YtA7vwTfsszGDXXMxoTbekaH6S6qJYy4WLfJhv kXjlHO+g3PWJE5Ssv4CE+DJQN51Uo1rIWvRtrUkr0bsMp1LejFmNvS5YTpa+6MkfqkkW 3h1H/4VkVGaKWPw1OQZVe5zRywFljcMVNkod4Mx3BaFFWmhVUceaYcV5Jqr5nPKLWek1 AbVnYBaJUu/z31rdhsT8W79NCqNZTTNWMy4gKfuVP6IQ+vXaB1tCOytCmRzNvLZh4olg N1lspjLgaDdfeemqv0KdVgdDNoQf67fF2RDGzZz0lBD+aegmKAVY8HJs6xBcNIntloMk kHmA== X-Gm-Message-State: AOAM532iI3g24HG1sdAIe8EvaOzsIUK+UYMEbwDEmPcNCWiJSiLpeSNy 65Wo7aYl3CULrsb2wjFY7tU= X-Google-Smtp-Source: ABdhPJwL+qgOM4mOwnX0G6peBtuRhX95dExnYOhp+TnsTuD6nUVtT1V5CBzcuSAhO+w4J3ZJhcDxvw== X-Received: by 2002:adf:e7ca:: with SMTP id e10mr1703697wrn.236.1600723163940; Mon, 21 Sep 2020 14:19:23 -0700 (PDT) Received: from localhost.localdomain (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id k4sm23325699wrx.51.2020.09.21.14.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 14:19:23 -0700 (PDT) From: Alex Dewar To: Subject: [PATCH v2] PCI: brcmstb: Add missing if statement and error path Date: Mon, 21 Sep 2020 22:16:24 +0100 Message-Id: <20200921211623.33908-1-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_171925_305975_E9331E76 X-CRM114-Status: GOOD ( 19.38 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [alex.dewar90[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [alex.dewar90[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Rob Herring , Florian Fainelli , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, Bjorn Helgaas , Jim Quinlan , Alex Dewar , Nicolas Saenz Julienne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org brcm_pcie_resume() contains a return statement that was presumably intended to have an "if (ret)" in front of it, otherwise the function returns prematurely. Fix this. Additionally, redisable the clock on the error path. I don't know if this code was tested or not, but I assume that this bug means that this driver will not resume properly. Fixes: ad3d29c77e1e ("PCI: brcmstb: Add control of rescal reset") Addresses-Coverity: CID 1497099: Control flow issues (UNREACHABLE) Signed-off-by: Alex Dewar --- Hi Jim, Here's a new version of the patch. I added the missing clk_disable_unprepare() and assumed that it would also be required in the case that the call to brcm_pcie_setup() fails. I didn't follow the suggestion of adding extra braces to the if-statement as the kernel style is not to add unnecessary braces in this case: https://www.kernel.org/doc/html/latest/process/coding-style.html?highlight=style#placing-braces-and-spaces Best, Alex drivers/pci/controller/pcie-brcmstb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 7a3ff4632e7c..8bae3a4f8e49 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1154,7 +1154,8 @@ static int brcm_pcie_resume(struct device *dev) clk_prepare_enable(pcie->clk); ret = brcm_phy_start(pcie); - return ret; + if (ret) + goto err; /* Take bridge out of reset so we can access the SERDES reg */ pcie->bridge_sw_init_set(pcie, 0); @@ -1169,12 +1170,16 @@ static int brcm_pcie_resume(struct device *dev) ret = brcm_pcie_setup(pcie); if (ret) - return ret; + goto err; if (pcie->msi) brcm_msi_set_regs(pcie->msi); return 0; + +err: + clk_disable_unprepare(pcie->clk); + return ret; } static void __brcm_pcie_remove(struct brcm_pcie *pcie)