From patchwork Thu Mar 16 20:10:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 1757978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=v8W0ye2f; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pcz1h1scNz1yWp for ; Fri, 17 Mar 2023 07:11:51 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Pcz1f2tXjz3f3L for ; Fri, 17 Mar 2023 07:11:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=v8W0ye2f; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=web.de (client-ip=82.165.159.35; helo=mout-xforward.web.de; envelope-from=markus.elfring@web.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=v8W0ye2f; dkim-atps=neutral Received: from mout-xforward.web.de (mout-xforward.web.de [82.165.159.35]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Pcz1F5551z3cd5 for ; Fri, 17 Mar 2023 07:11:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1678997455; i=markus.elfring@web.de; bh=NJehBpfANBOx/ezWyZUCAvWbKx1kcW7n4bvZoD8TpaQ=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=v8W0ye2fkugR4KgoOh9C4kdXIelfhmbRqeWLu9o27zkQ0a6wvBZXtZmI+/gw1Upwp hR9Zy+aXAC7BefwNMzPDeV3mXz8vpW6J4nKryFAI8Q+m1c6/Msymldv+rNKDSvThNq dyNNJ15rNqp9Zbii/uX6zzv1abBfEO5y7rOl65kFshDf2RPpto4qshF02EAHR1Bb0s SQ0JemftNkm/ekVvYlwDOstoCIL2xz0JKQ3Iiry0MV1uqLyLVlxUMCm1QAsD7uX0x2 bknld3AOFXGG6/K9qjXDHQxaguYfic/KmZqO0hgZQZqsGYQPTwSiqd3jib6m+JmuNK Ai9dTdz3ZcE8w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MbTGt-1qEAUg2AlF-00bpK4; Thu, 16 Mar 2023 21:10:55 +0100 Message-ID: <2e2fbd6f-e622-51b7-a19a-2662d8ca2d7f@web.de> Date: Thu, 16 Mar 2023 21:10:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH 1/4] powerpc/4xx: Fix exception handling in ppc4xx_pciex_port_setup_hose() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Christophe Leroy , Josh Boyer , Michael Ellerman , Nicholas Piggin , Stefan Roese References: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> In-Reply-To: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> X-Provags-ID: V03:K1:AFPFzq0Hm3EampbJTO1eJVYq/TgVy94+UYS/xxmOuwBuye8QQtC wm1bNnk01LchWC7LsKHHHd8eeyyxt24VU+U/NugN+vVPVeBHp4rD6SLj/OqxfoCmYY9QHy9 UidGfl0x69SE2CCUIhX9QjkK+TIjo7eAMKFm0V2g1VkUnvYVAAQ7hmCbTTVthvLp5N0T8dw XXgo0eGGxUTUpAIjVDf2w== X-Spam-Flag: YES UI-OutboundReport: junk:10;M01:P0:LAZInxG/gXw=;emAv+Ik2TA2W2Joq7VsCNm2pjiSPt TmRShLIQ857l1AaALkhmRuRU3dyzOeHud9yDxCJv25WcZuFgjljtlbLubyIP4Z5IDwEKLf9tt PFIsUVgB/BsUo4B+TdpzcuH7+uINz3JcISG/09f7gUvRf0mqnmUP+bgf6gbpLkqjdmUnZoQBf gmkLUHxInC5Ka3bU0ehAGdZZsLBZHThopRpBE4go/ZEXaG09R1JtD9Em+cUPwO2l3tesGKkn2 FugD9ZiRimJkoMxa5obmBcc0unKNxQu36Zjj/DM3J4P5zo62PCbjk7DSwce6Ctdxv+0jCYuBF i9M/MA6nB1T2wr41FbavCn7I9XGJQCBMW/9CSA2xT4bN3AzHr7Iozjcz6L1v/smdVqyDRwOtO A+A+OLBmuggULTdT6M6FO2XDj6pAeGeTUDSUpFlc0m1DBBxitr/pky4C7yWU+sRUNLaQ1RFpe dsOAEwSHHr7CIh46I6DaGL7jqXwyQjoFtU0GqgmmKZAPYaJde77E+8An2HDkKRAZULLDp4Ahh IX7qtJde5yrL2tmL/ii4SclEn4/fVv4ayYxgdlfGiUGWGmXEvjbxMiWHjclgnA/Ly+Kuj4nKY 6oMAib6iYJ3bof4WBvE16Cnep5nXDG6E9x90zUrhzny5X3d9lPNACbTTsNVbJyMUpBhbG/dPu qjjMdbmfrxKqF3FwyctbNExptw3Xt9vQvOUhtUXUNPWKXaHELAyC/8uivZywQySGwirlIqcxg lVULjBl86WrYsiJv9jtNuGF8414PWSr59q/xNxjSzCwbQNxCVOIO0vyj3727PohVuHBbq36Qw bBO9VaF7Y8BFK0bY5dyMgQPvfoJzFR2LwZ59ToxpWy2i5VXPzY0vV22WZjZxNkkAr8BK5dg9d NC0JjJU8VVJc8UD2X9QyaL0Kr6BKbx8/2iMo10Dl3JneKTJcauNkwgTaXB34/AYbhTwUQDL6g ypOnpHcAmZ0wY2isJjGdXc0fartVufN7E9UJP5UNRW8f9k6DlTSlpNq3Hbww0kjB5w8/Fj95X YmW/jayRCvLX1FfU= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LKML , cocci@inria.fr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Date: Thu, 16 Mar 2023 19:00:57 +0100 The label “fail” was used to jump to another pointer check despite of the detail in the implementation of the function “ppc4xx_pciex_port_setup_hose” that it was determined already that the corresponding variable contained a null pointer (because of a failed function call in three cases). 1. Thus return directly after a call of the function “pcibios_alloc_controller” failed. 2. Use more appropriate labels instead. 3. Reorder jump targets at the end. 4. Delete two questionable checks. This issue was detected by using the Coccinelle software. Fixes: a2d2e1ec07a80946cbe812dc8c73291cad8214b2 ("[POWERPC] 4xx: PLB to PCI Express support") Fixes: 80daac3f86d4f5aafc9d3e79addb90fa118244e2 ("[POWERPC] 4xx: Add endpoint support to 4xx PCIe driver") Signed-off-by: Markus Elfring ---  arch/powerpc/platforms/4xx/pci.c | 19 ++++++++++---------  1 file changed, 10 insertions(+), 9 deletions(-) -- 2.39.2 diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c index ca5dd7a5842a..7336c7039b10 100644 --- a/arch/powerpc/platforms/4xx/pci.c +++ b/arch/powerpc/platforms/4xx/pci.c @@ -1930,7 +1930,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)      /* Allocate the host controller data structure */      hose = pcibios_alloc_controller(port->node);      if (!hose) -        goto fail; +        return;        /* We stick the port number in "indirect_type" so the config space       * ops can retrieve the port data structure easily @@ -1962,7 +1962,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)          if (cfg_data == NULL) {              printk(KERN_ERR "%pOF: Can't map external config space !",                     port->node); -            goto fail; +            goto free_controller;          }          hose->cfg_data = cfg_data;      } @@ -1974,7 +1974,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)      if (mbase == NULL) {          printk(KERN_ERR "%pOF: Can't map internal config space !",                 port->node); -        goto fail; +        goto recheck_cfg_data;      }      hose->cfg_addr = mbase;   @@ -2007,7 +2007,7 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)        /* Parse inbound mapping resources */      if (ppc4xx_parse_dma_ranges(hose, mbase, &dma_window) != 0) -        goto fail; +        goto unmap_io_mbase;        /* Configure outbound ranges POMs */      ppc4xx_configure_pciex_POMs(port, hose, mbase); @@ -2064,13 +2064,14 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)      }        return; - fail: -    if (hose) -        pcibios_free_controller(hose); + +unmap_io_mbase: +    iounmap(mbase); +recheck_cfg_data:      if (cfg_data)          iounmap(cfg_data); -    if (mbase) -        iounmap(mbase); +free_controller: +    pcibios_free_controller(hose);  }    static void __init ppc4xx_probe_pciex_bridge(struct device_node *np) From patchwork Thu Mar 16 20:14:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 1757981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=BJz5lzuJ; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PczXV0RMcz2473 for ; Fri, 17 Mar 2023 07:35:06 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PczXT6CPPz3f3t for ; Fri, 17 Mar 2023 07:35:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=BJz5lzuJ; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=web.de (client-ip=82.165.159.45; helo=mout-xforward.web.de; envelope-from=markus.elfring@web.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=BJz5lzuJ; dkim-atps=neutral Received: from mout-xforward.web.de (mout-xforward.web.de [82.165.159.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PczX800B8z2xWc for ; Fri, 17 Mar 2023 07:34:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1678998876; i=markus.elfring@web.de; bh=kRXnLO2ui0IMpfiwle1MqHNK3tspqGWzZeAWDMFraSw=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=BJz5lzuJ3qB5keYHNOeuvhlrXN16lNaWtfSCAOILB05SVlaYb7ajzIAOh4nKeFQve JI4CPEG8S6+zFuRmhEznKP+CeKejwdrs8eNrovdUt/dxDaEvXh1eyd6EEX21QOBOTJ undeOpZGL4uY5MIlmLZcmXG268CVruqLUmw6vJZX3ABgmhViXTA7vYk2VaaBFzMWZC NAbHd1dJDkTUCJRaRYJUrYSfbgNgrvSDPq/Vuq2HbTgO00zjRm/pVhvnbOehJFNSDe 9oBzMOxpP2rpH92IJBA4gnbal2xWmmPbTcDjE177w2V9s03VOYwuC2Sehq7Yb9x72G D33Bl1uaBEojA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MJFhJ-1pvnmc23kh-00Ks64; Thu, 16 Mar 2023 21:14:17 +0100 Message-ID: <1f1a8941-88a8-b2fa-b186-4e57e6809a10@web.de> Date: Thu, 16 Mar 2023 21:14:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH 2/4] powerpc/4xx: Fix exception handling in ppc4xx_probe_pcix_bridge() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Christophe Leroy , Josh Boyer , Michael Ellerman , Nicholas Piggin , Stefan Roese References: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> In-Reply-To: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> X-Provags-ID: V03:K1:W/SenVddO6zSi7R7Rvoxm8cJ3SoVMgH9Af2rTLPqG2yFnxWq16L lALK3qEjWhNkMr5Q+bZCVasFyA+Lu61a8VkpmFv4ko6aYzkQtGFta3Q15GKRhfwlW+qwpLm eTV9O3Run/B89N2pdscJ5zp/HKgmy/L7B1Lz+Eh4zhckFTWITYE4H3zoXNKTwBLVW0FoGlR 6UWQ6XmM+Qc+qrXo4e5zw== X-Spam-Flag: YES UI-OutboundReport: junk:10;M01:P0:Z7mm6Z7MOpM=;TF3t44fexcsM8LrgNc6WC8u3zaNcR kZOtg+30WtX9vRYjI7kfh2ywRiQSFVoYVrZga/y4GZmivLPh9jlUhvCjE23+297RfAODpQc9T fjZGkkccMsXdJSfFXUaQ1xjCidjt5/i53/g1bEItRblMaXkAo+t+fRkAo3wUzjJR1fgpV8gTN 7YHqJ04xbBsbyXg9A+bYORPR6lUWUn55u0umnN3e/okjC0afvLm5sI2hI7eOfqzy/kecRze5e sOyj0o4pOq5DkRRlJGlegf5yrNCggADHF9nmiTJhx9mD+p5uqLLbVmTEQVdAYUnudybn6gnLQ tTmmnLmX8pNBUaa3I/SeFfuuHZVA4v1/BBRypqbSaJoJs1MBeEWR01Z8zjLlE8TWv+Zu0BtGk fmJCoRxal2ipMKDQo1k+vGQcAmnbjfCkZnO75lbnhMPJqcgA7zzDuKbs+U9P8tcfWJsi/o3qV lzGeAxNwMLrhHDD+cXq6O+QOMkX1uIyF/ynVSH1PvEX3J5j7Qwz/nMYxkjoIWAc38mJvPvJer jzFHSr4mhJdPfVTANjF870TRZQEa6AzdknVp6hv8hi5suQuZjt9lYpZ47G35E/zgmAt8bcFt0 Qb9f6KKzh/NxAND9F1JExxrd8ifh/pr0fwMBALq+aMAe6tZx2aaZScBl3O9oTpnfKL5IRQj4b JpB0Ne49bna3Z51EFRRNCa0Zaj7RmTWnjCViEq8EjNOEDWH3edahHjmKFBuhKRcRo8Z4YKaCE dD7JyAUzT0wOgW6UIk8zpX2yEK/cbVPrghzJO806f+q9I76VrTEPlbewkHQKh7jp7mQ/w+AAm BbXAKcBKBwDGIXhgQuTh+fb4lUWgy9wBPZZAoTQsvfNYPOKo1cSiRPx/QAjuuzCb9Bh2hNKNN 9VfzbDkGfZMTByJrk9T1+NzwD7vEoOHoH1M27Mj9lF6DywiC6+Y5jQ5SPlcVMnG7lvPhI0k3R 6HUD++/Omwmyo0vwYzeGysC83PQ3wOBZtyYLMPjtKNpfzdeZX0mLa0bPEx4r7NPB6tzfcJdxq wujJwdfSs4M2YhW8= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LKML , cocci@inria.fr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Date: Thu, 16 Mar 2023 19:09:33 +0100 The label “fail” was used to jump to another pointer check despite of the detail in the implementation of the function “ppc4xx_probe_pcix_bridge” that it was determined already that the corresponding variable contained a null pointer (because of a failed function call in two cases). 1. Thus return directly after a call of the function “ioremap” failed. 2. Use a more appropriate label instead. 3. Delete two questionable checks. 4. Adjust the exception handling for another if branch a bit more. 5. Remove a return statement at the end. This issue was detected by using the Coccinelle software. Fixes: 5738ec6d00b7abbcd4cd342af83fd18d192b0979 ("[POWERPC] 4xx: PLB to PCI-X support") Signed-off-by: Markus Elfring ---  arch/powerpc/platforms/4xx/pci.c | 18 +++++++-----------  1 file changed, 7 insertions(+), 11 deletions(-) -- 2.39.2 diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c index 7336c7039b10..fdf13e12ca9d 100644 --- a/arch/powerpc/platforms/4xx/pci.c +++ b/arch/powerpc/platforms/4xx/pci.c @@ -564,13 +564,13 @@ static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)      reg = ioremap(rsrc_reg.start, resource_size(&rsrc_reg));      if (reg == NULL) {          printk(KERN_ERR "%pOF: Can't map registers !", np); -        goto fail; +        return;      }        /* Allocate the host controller data structure */      hose = pcibios_alloc_controller(np);      if (!hose) -        goto fail; +        goto unmap_io;        hose->first_busno = bus_range ? bus_range[0] : 0x0;      hose->last_busno = bus_range ? bus_range[1] : 0xff; @@ -595,8 +595,10 @@ static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)      pci_process_bridge_OF_ranges(hose, np, primary);        /* Parse inbound mapping resources */ -    if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0) -        goto fail; +    if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window)) { +        pcibios_free_controller(hose); +        goto unmap_io; +    }        /* Configure outbound ranges POMs */      ppc4xx_configure_pcix_POMs(hose, reg); @@ -605,14 +607,8 @@ static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)      ppc4xx_configure_pcix_PIMs(hose, reg, &dma_window, big_pim, msi);        /* We don't need the registers anymore */ +unmap_io:      iounmap(reg); -    return; - - fail: -    if (hose) -        pcibios_free_controller(hose); -    if (reg) -        iounmap(reg);  }    #ifdef CONFIG_PPC4xx_PCI_EXPRESS From patchwork Thu Mar 16 20:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 1757982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=fsCsB/xy; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PczZS6Qvqz1yWp for ; Fri, 17 Mar 2023 07:36:48 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PczZS2c81z3f3M for ; Fri, 17 Mar 2023 07:36:48 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=fsCsB/xy; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=web.de (client-ip=82.165.159.45; helo=mout-xforward.web.de; envelope-from=markus.elfring@web.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=fsCsB/xy; dkim-atps=neutral Received: from mout-xforward.web.de (mout-xforward.web.de [82.165.159.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PczZ65QMlz2xWc for ; Fri, 17 Mar 2023 07:36:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1678998984; i=markus.elfring@web.de; bh=wEB5ErETjmtlUGuUHVx9sABUc+9Jv6PEUoAIprRd7Fk=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=fsCsB/xyQYku6rIQzocNYY8nitDA+v9SDG2puVWbzrfrMtFVb9npyaCEkKzjXXyQX 33YvM0fExBThOZVVxRSkvU0cSOXqkGL9l5RTO3k+OyuuB2e6DjrQsVBYVmZa6k0i8S 0+wQRCoMcMzlPvzXNoBENo8T6Gm7/unJQMsx1vEbGivgK/7oq4RJ9Kpl2JESUDow8k z6HxjQ/Ko16449E1DkWWUYXDAtPfHiQ8gxtdoBx+yKWFrJG9ErysX5C3tQd30F2k08 okxZfc0amgWyfqUl1e3/GIaYvvAz3yrd6/DtbShspnDDIwONzbJ6m5wBqzsfLNZREq Cy3B4JxmDonRg== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M4bUq-1pdSW62KJi-001pWF; Thu, 16 Mar 2023 21:16:08 +0100 Message-ID: <4aa9785d-5992-91c0-c0ba-700192749f78@web.de> Date: Thu, 16 Mar 2023 21:16:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH 3/4] powerpc/4xx: Fix exception handling in ppc4xx_probe_pci_bridge() Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Christophe Leroy , Josh Boyer , Michael Ellerman , Nicholas Piggin , Stefan Roese References: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> In-Reply-To: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> X-Provags-ID: V03:K1:pWV71kn+c5dWxe51sgQahx/fm6J1XSXSZMsibRW9PN+PZ8Herh3 AclVr+svcQxcHz5td5Qy4z+rYMf8uro3mfabBDgkpSnI6KLsOdBnBd5wi02pYqg8VYFfHDv TwYWWDHPB+qri9hVt9bOB3GTXlE2dk5gmFuSQacb85iruV/7STQP1wXhF1nOM+PNF8GRazH zV1iV+SO3/sg24xzup+hw== X-Spam-Flag: YES UI-OutboundReport: junk:10;M01:P0:9kVJwgAcnB0=;IKNYr5CIVzcNpejTmGpz5L4ly2cQd mFUJuik5L1FR3yura230II+9X7Ehi8Qrq6RAl1ImkmpWDxPnFbFIBu6KGifaovV0ZzvvA0MbQ bREx9wvolEmUBPa+ocfJyPQDL72FzQ/AObU8TqaccVzpM33x2TW+XqPbrXlrdkEqJ+Mq8dZC9 UXbyaxh/q6mMPKwoGy51gdAStGqANyg1gsl11OUQNId2WSnG8zmJAaQGIcKCsjq9x//lfX0ZD 8giGJw1h7qtyrnQmWQWoFr/XAOq2lpow/o5Pl7tOF1/cqxsB7aVpAUjUjHIqwxDHgKw7Usn7q 1d1NCDuJY3eJU1mUcCe7SxY912rvcoalWSRoyixtIB8xa52fgvQpAyjvbtSFZsKxpC5sV4BZd XwFb/xzgrPJAoQqwguMni/rM6qWwNFWJEwI3qciVV2MXadvt4aVakV3Hhg/SUwegod9t75+iU Gz9ErCN772yiuHnTsCsm3arVaUTK33z+q6k6Uq1l6PrQ9OeoStv2jTEoMcLbrIeFYDgFiraO6 07q+kD04vlCLBw7HJvalnb/1cXsyfEUrJ06izW2XCjCJ42cQWBTcibJ5CHSEprhafxHRYtEO3 86MwWdVdF8/aitVEymoWEK9w/+OEp7cc9N3Vu256+5QjHD4uALcSkPlOBa2dtRBL2in7b4gw8 GRmDoBpGwW733J95qMTFMyWYA6cKLveiFXoqZfsx4grAHvCizOhIvbIms0PzBEoh66V4K6hI4 zbI6v+6IcjGysIp4skeHRiYnXEPIv4Jcp6HbagERbVVKdBouq9K0Ay/czJfkDhNfqkh7MY0fm q3YJE0sSOjOeAFn5sc0L49MF8i0VyI5W0kEd3E+EBbpvgqBb+dP77+oYUKgwXAWjD+kwL57TG fIZwFJ5GYfJdKh4LjxJXKK1TTF89akj4LbsW4F2oGSckWCt17h6u6DDrklSgesikHppRlsHRm lvCK40vACTg+Sbq12PrlHuv+D5AqiW9dnSgafihLldmPSbDBFCrKP1i1IGGthaBb46ZiutkkF ccPgV4Qxg+6iyjlE= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LKML , cocci@inria.fr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Date: Thu, 16 Mar 2023 19:12:10 +0100 The label “fail” was used to jump to another pointer check despite of the detail in the implementation of the function “ppc4xx_probe_pci_bridge” that it was determined already that the corresponding variable contained a null pointer (because of a failed function call in two cases). 1. Thus return directly after a call of the function “ioremap” failed. 2. Use a more appropriate label instead. 3. Delete two questionable checks. 4. Adjust the exception handling for another if branch a bit more. 5. Remove a return statement at the end. This issue was detected by using the Coccinelle software. Fixes: c839e0eff500af03de65e560c2e21c3831586e6e ("[POWERPC] 4xx: PLB to PCI 2.x support") Signed-off-by: Markus Elfring ---  arch/powerpc/platforms/4xx/pci.c | 18 +++++++-----------  1 file changed, 7 insertions(+), 11 deletions(-) -- 2.39.2 diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c index fdf13e12ca9d..0c0848f0c819 100644 --- a/arch/powerpc/platforms/4xx/pci.c +++ b/arch/powerpc/platforms/4xx/pci.c @@ -358,13 +358,13 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)      reg = ioremap(rsrc_reg.start, resource_size(&rsrc_reg));      if (reg == NULL) {          printk(KERN_ERR "%pOF: Can't map registers !", np); -        goto fail; +        return;      }        /* Allocate the host controller data structure */      hose = pcibios_alloc_controller(np);      if (!hose) -        goto fail; +        goto unmap_io;        hose->first_busno = bus_range ? bus_range[0] : 0x0;      hose->last_busno = bus_range ? bus_range[1] : 0xff; @@ -383,8 +383,10 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)      pci_process_bridge_OF_ranges(hose, np, primary);        /* Parse inbound mapping resources */ -    if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0) -        goto fail; +    if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) { +        pcibios_free_controller(hose); +        goto unmap_io; +    }        /* Configure outbound ranges POMs */      ppc4xx_configure_pci_PMMs(hose, reg); @@ -393,14 +395,8 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)      ppc4xx_configure_pci_PTMs(hose, reg, &dma_window);        /* We don't need the registers anymore */ +unmap_io:      iounmap(reg); -    return; - - fail: -    if (hose) -        pcibios_free_controller(hose); -    if (reg) -        iounmap(reg);  }    /* From patchwork Thu Mar 16 20:18:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 1757983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=tUxTjQkQ; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pczd9234Dz1yWp for ; Fri, 17 Mar 2023 07:39:09 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Pczd86W4Sz3cjN for ; Fri, 17 Mar 2023 07:39:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=tUxTjQkQ; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=web.de (client-ip=82.165.159.35; helo=mout-xforward.web.de; envelope-from=markus.elfring@web.de; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=web.de header.i=markus.elfring@web.de header.a=rsa-sha256 header.s=s29768273 header.b=tUxTjQkQ; dkim-atps=neutral Received: from mout-xforward.web.de (mout-xforward.web.de [82.165.159.35]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Pczcr1ZvKz2xWc for ; Fri, 17 Mar 2023 07:38:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1678999124; i=markus.elfring@web.de; bh=yRVNOUfOjIhUPee+fsAseodxf2S6OlCum8nReJFE93E=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References:In-Reply-To; b=tUxTjQkQ7qmrjjTm3Aw0xyEHhXJrTo5Q0Jpe8B+Lls4cEwMQFkFEmvFIOWRaybNEw kD8G01jFz/Fqer7ZvR9zY3Tl8YyMUN25gjSzeisPRBC5F8JnOGE4sq0YLqo8+/xUJm fX0MYZZ8v0IlIIFctUjPBg/NiRScBCnZxCKcJq1Igi6GPslTuv3X4jBxLeCAuvk3mA pCzCHefJwFe1q+e4m/sPvcyIrKw4usgLkyxfwYacya0FRGUDxEkj4FQnJkVmt1N2na yh/IQTHJCNtcsom9Ky/kwEVRQUewYG87PIkW5yQuzB7LogY/ITYJvMupmQDRrjmoys rkv5CyzdE4Vag== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.83]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MQPZj-1ppjyW2Y3V-00MLmY; Thu, 16 Mar 2023 21:18:13 +0100 Message-ID: <349247ba-a539-2a36-0371-93a8f59d2975@web.de> Date: Thu, 16 Mar 2023 21:18:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: [PATCH 4/4] powerpc/4xx: Delete unnecessary variable initialisations in four functions Content-Language: en-GB From: Markus Elfring To: kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Christophe Leroy , Josh Boyer , Michael Ellerman , Nicholas Piggin , Stefan Roese References: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> In-Reply-To: <72a7bfe2-6051-01b0-6c51-a0f8cc0c93a5@web.de> X-Provags-ID: V03:K1:v5sxuo7kDJ5P/yxyZ+V2WDJ7myWWQ9vYnkaF7vGJ9Yc7F09yr6H 1Nk7mYpmcD19JSqxExH7u01veIt3FvRCZZUh2fOvgQ8U2HviY84gTDL3SDZAzWVTFBJwETo ggL/fjNKn4DG/1/XkX8P+pQ6I+hTBhsHW3lEB2S2n22ktWlFqcTUq94vXV+P4HStmT90bN+ J8oXcs3FZrMOSTkstHQqQ== X-Spam-Flag: YES UI-OutboundReport: junk:10;M01:P0:wOhVZOuePdk=;FRPb3rW6EGgP/qav5XR+fbvmv3QEQ KxbJefXXdZPd50GcqK4okf/GhK9pCmbxNG1vRtsVknsagr+yPGfRLwa5IUvb1Vxb+tnK7GMfz zUB6bmgSHUdgl2QRQ1kp0G5vol8feM0hMfNzEMCni0oo4WNQsgUsxLKM/BPFk/feEc2SlPyR7 Cb7lYql3UKYQacvCP4g5Zj70QfdOjkXANfm7qyHz4roXRzPzO6pDQNPeoA3Djw2MEeid+WmcU noVmfvyales7VfC04LqG8EfHwFxPRZrLq8lN6g+KWKWUyXldPPhdjl+UNFNT9Unuazy/zxMQl +Mk2cgf6gtv1BQbcARf512RsK9zdy8OlMj3nFBxM1oNZN0FaCIXgtkY3Rb+987IWSrqhOQlok pB0zyAjAdS3BGuueCNFW3NVme6GdrXNHj/JzZkYu0B0hhJrthkq498VSPsTx28lx8dCM1j57g IL7jfjDM8PstGLNv4ADsHsPQy7P/W5SJbygxH0Vul6zKbnrNnwiFM4Mtr5VrZGZdC1qLn4XaG SQOzPcARcxnbASpHbJ0pt3ubcJw4Ix5izXPWIHxxkdjisyBt8gQ3/NLmSzSKequCgVX9BoiMP OMxC6RWVWlfSSn10LRZ0zRqtW6x4/awbA4DZwEYDSGb5KehwNaBibuHy36ws/wfDPMpDWJUye bbScx8tra3Bts49AsfXC+2wPojN2uzZgf4nYCUeXHAbhwKaoidInlB/JMI6hW2HBfjS1qTYUe RMfM4m7/HZE/u1ADzOlScDxJCx8fj5hTw9otKt7JzrgKyPd+VEwSxwf9ToHnoouwsFJ9x7R77 zpCpHzKHd8C9Bkv1Ts0xd1VStV9/kXBH3uiOHFpnR98w68i9779V/EpiiHcEknmT21fEaznir BZ+zKdxlh5O4ABfJAa1ebyrzYkv0oNMVULdz5ykgjoBS9nTtg5RWIcmrhuLma0PML3gOxfeX1 LGrS237xyx1iU8S66A8Y85TlE30Q5Ov1sH9ggrwfgDDRBo66isT19WDrSABHjHvuVmv86Z/5O ngRHyZnkhaAZbSgg= X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LKML , cocci@inria.fr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Date: Thu, 16 Mar 2023 19:56:21 +0100 Some local variables will be set to an appropriate value before usage. Thus omit explicit initialisations at the beginning of these functions. Signed-off-by: Markus Elfring ---  arch/powerpc/platforms/4xx/pci.c | 14 +++++++-------  1 file changed, 7 insertions(+), 7 deletions(-) -- 2.39.2 diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c index 0c0848f0c819..ebc030e12663 100644 --- a/arch/powerpc/platforms/4xx/pci.c +++ b/arch/powerpc/platforms/4xx/pci.c @@ -323,8 +323,8 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)      struct resource rsrc_cfg;      struct resource rsrc_reg;      struct resource dma_window; -    struct pci_controller *hose = NULL; -    void __iomem *reg = NULL; +    struct pci_controller *hose; +    void __iomem *reg;      const int *bus_range;      int primary = 0;   @@ -523,8 +523,8 @@ static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)      struct resource rsrc_cfg;      struct resource rsrc_reg;      struct resource dma_window; -    struct pci_controller *hose = NULL; -    void __iomem *reg = NULL; +    struct pci_controller *hose; +    void __iomem *reg;      const int *bus_range;      int big_pim = 0, msi = 0, primary = 0;   @@ -1403,7 +1403,7 @@ static struct ppc4xx_pciex_hwops ppc_476fpe_pcie_hwops __initdata =  static int __init ppc4xx_pciex_check_core_init(struct device_node *np)  {      static int core_init; -    int count = -ENODEV; +    int count;        if (core_init++)          return 0; @@ -1905,10 +1905,10 @@ static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,  static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)  {      struct resource dma_window; -    struct pci_controller *hose = NULL; +    struct pci_controller *hose;      const int *bus_range;      int primary = 0, busses; -    void __iomem *mbase = NULL, *cfg_data = NULL; +    void __iomem *mbase, *cfg_data = NULL;      const u32 *pval;      u32 val;