From patchwork Sat Jul 23 10:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9244589 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 910A160459 for ; Sat, 23 Jul 2016 10:59:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8110C209CD for ; Sat, 23 Jul 2016 10:59:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 754E42623D; Sat, 23 Jul 2016 10:59:46 +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,RCVD_IN_DNSWL_HI autolearn=unavailable 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 0C061209CD for ; Sat, 23 Jul 2016 10:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751437AbcGWK73 (ORCPT ); Sat, 23 Jul 2016 06:59:29 -0400 Received: from mout.web.de ([217.72.192.78]:64039 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbcGWK71 (ORCPT ); Sat, 23 Jul 2016 06:59:27 -0400 Received: from [192.168.1.2] ([78.53.49.29]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MgO8g-1bebWF1H4Y-00NfEn; Sat, 23 Jul 2016 12:59:17 +0200 Subject: [PATCH 2/3] IB/mthca: Less function calls in mthca_reset() after error detection To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Sean Hefty References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <546CE09B.9090101@users.sourceforge.net> <55b7a06e-6bb4-f1bb-e4dd-7812648ecf34@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <060a2178-afb2-28a3-9568-25c124972062@users.sourceforge.net> Date: Sat, 23 Jul 2016 12:59:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <55b7a06e-6bb4-f1bb-e4dd-7812648ecf34@users.sourceforge.net> X-Provags-ID: V03:K0:GyCqIIymQIJNbf6TF6LyugUDw36fYQu5Lh4hgvRpQ8JuOloW7oS Bm2GQupSMk7UU7VRplMQ8liVNXVVOgoDszeOQZAEORX6jtNLjPrpfI9ve0KAWm42BdSNRnC Cnmd9nn/EWAEthXGEktrZJhI4dzU4PqWaL4qr3/YArNWUnOwi3CCzC7T6S2kVWD/rPU6Uvf I8Bb2pCAsBuoTSb3kzJRw== X-UI-Out-Filterresults: notjunk:1; V01:K0:7gUriGijZ/U=:JnnoH1CIH4OQN7sOQPisf1 Y16G9uNcFzlSL4HbDQZVz6ZibeRxFBGUVYsAtrRZYB0YuoG0ks40SPPFqhNWYzY5CLsl5z9Kn /HGyW0neiQHZxIrINI9FPGd3ovF0xWS3ENjpEw8PvcNWZMd1SOrPzruqwGwESoIqt6WzualI3 ZHGuU9rOeMtYPOoYiHA55NfA2ewoo7UE7RU1U1DjxeDN2tVkPpuzaz1UXlbqxlsv4Y7FafWhI xWITkW8OE6zBktxaOnaNeGFIhM916heb/w/ENz7U4K0dftXCXRygQf8TJRdq0tlpH9bSShXEg 4Jxv/gZd+jh4AknRbus5n3kY2yV00FGdYmofDzIZ/apapB8vS54yAi0oqXFnQUH00poa4dFyl uy85gFmSGw8goywzjn/yHcBlR/ZXYWrs9rtDShMLINOfuIFAcRqvelW1yJmcVrM07TX3JlD0j u68SP7ZedoND8yLCcdh9XMfZPLQAh5FxjahFQ8opRhcVILwq3W5lXVh8fqmKA1Zwp4BqLANh5 Qs2TLJC+N9SYs9O8wCi8hJXrZui92PVsnomQEiRZQFfvVrADKCnZBMFoXzP6pmCNLaSRgdYlW FbsSlRnf47cXq0M3+vazP4GxVTH/gmowtLeK2KSYcAz5Syehk7P/0fOjOWY2OmnXVd7qIAwBe EMDHPJBflw6h55uFDX6H0wAY+TqgqPZxsDHzlWS0ZlprISE7Z7q0CrFqGH2FGCutMBa6PaasP irqxPUFltYKUs1HAtENAakkL0K932bUdr6fh/ze5N/VQzWhhq9iPHA4LsH4sw3gUb4RRKK+Ah 4MCuHSv Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 23 Jul 2016 11:28:30 +0200 The kfree() function was called in a few cases by the mthca_reset() function during error handling even if the passed variables "bridge_header" and "hca_header" contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring Reviewed-by: Leon Romanovsky --- drivers/infiniband/hw/mthca/mthca_reset.c | 41 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c index c521654..6727af2 100644 --- a/drivers/infiniband/hw/mthca/mthca_reset.c +++ b/drivers/infiniband/hw/mthca/mthca_reset.c @@ -98,7 +98,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM; mthca_err(mdev, "Couldn't allocate memory to save HCA " "PCI header, aborting.\n"); - goto out; + goto put_dev; } for (i = 0; i < 64; ++i) { @@ -108,7 +108,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV; mthca_err(mdev, "Couldn't save HCA " "PCI header, aborting.\n"); - goto out; + goto free_hca; } } @@ -121,7 +121,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM; mthca_err(mdev, "Couldn't allocate memory to save HCA " "bridge PCI header, aborting.\n"); - goto out; + goto free_hca; } for (i = 0; i < 64; ++i) { @@ -131,7 +131,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV; mthca_err(mdev, "Couldn't save HCA bridge " "PCI header, aborting.\n"); - goto out; + goto free_bh; } } bridge_pcix_cap = pci_find_capability(bridge, PCI_CAP_ID_PCIX); @@ -139,7 +139,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV; mthca_err(mdev, "Couldn't locate HCA bridge " "PCI-X capability, aborting.\n"); - goto out; + goto free_bh; } } @@ -152,7 +152,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM; mthca_err(mdev, "Couldn't map HCA reset register, " "aborting.\n"); - goto out; + goto free_bh; } writel(MTHCA_RESET_VALUE, reset); @@ -172,7 +172,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV; mthca_err(mdev, "Couldn't access HCA after reset, " "aborting.\n"); - goto out; + goto free_bh; } if (v != 0xffffffff) @@ -184,7 +184,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV; mthca_err(mdev, "PCI device did not come back after reset, " "aborting.\n"); - goto out; + goto free_bh; } good: @@ -195,14 +195,14 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA bridge Upstream " "split transaction control, aborting.\n"); - goto out; + goto free_bh; } if (pci_write_config_dword(bridge, bridge_pcix_cap + 0xc, bridge_header[(bridge_pcix_cap + 0xc) / 4])) { err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA bridge Downstream " "split transaction control, aborting.\n"); - goto out; + goto free_bh; } /* * Bridge control register is at 0x3e, so we'll @@ -216,7 +216,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA bridge reg %x, " "aborting.\n", i); - goto out; + goto free_bh; } } @@ -225,7 +225,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA bridge COMMAND, " "aborting.\n"); - goto out; + goto free_bh; } } @@ -235,7 +235,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA PCI-X " "command register, aborting.\n"); - goto out; + goto free_bh; } } @@ -246,7 +246,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA PCI Express " "Device Control register, aborting.\n"); - goto out; + goto free_bh; } linkctl = hca_header[(hca_pcie_cap + PCI_EXP_LNKCTL) / 4]; if (pcie_capability_write_word(mdev->pdev, PCI_EXP_LNKCTL, @@ -254,7 +254,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA PCI Express " "Link control register, aborting.\n"); - goto out; + goto free_bh; } } @@ -266,7 +266,7 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA reg %x, " "aborting.\n", i); - goto out; + goto free_bh; } } @@ -275,13 +275,12 @@ good: err = -ENODEV; mthca_err(mdev, "Couldn't restore HCA COMMAND, " "aborting.\n"); - goto out; } - -out: - pci_dev_put(bridge); +free_bh: kfree(bridge_header); +free_hca: kfree(hca_header); - +put_dev: + pci_dev_put(bridge); return err; }