diff mbox series

[v2,1/4] powerpc/4xx: Fix exception handling in ppc4xx_pciex_port_setup_hose()

Message ID e68a714b-32f2-de9f-066e-99a3f51a264f@web.de (mailing list archive)
State Changes Requested
Headers show
Series powerpc/4xx: Adjustments for four function implementations | expand

Commit Message

Markus Elfring March 25, 2023, 3:36 p.m. UTC
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 <elfring@users.sourceforge.net>
---
 arch/powerpc/platforms/4xx/pci.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

--
2.40.0

Comments

Christophe Leroy Oct. 3, 2024, 12:42 p.m. UTC | #1
Le 25/03/2023 à 16:36, Markus Elfring a écrit :
> 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 <elfring@users.sourceforge.net>

Looks like you have messed up your patches, there is no much we can do 
it seems:

$ b4 shazam e68a714b-32f2-de9f-066e-99a3f51a264f@web.de

$ LANG= b4 --no-stdin shazam e68a714b-32f2-de9f-066e-99a3f51a264f@web.de
Grabbing thread from 
lore.kernel.org/all/e68a714b-32f2-de9f-066e-99a3f51a264f@web.de/t.mbox.gz
Checking for newer revisions
Grabbing search results from lore.kernel.org
Analyzing 123 messages in the thread
WARNING: duplicate messages found at index 1
    Subject 1: btrfs: Fix exception handling in relocating_repair_kthread()
    Subject 2: powerpc/4xx: Fix exception handling in 
ppc4xx_pciex_port_setup_hose()
   2 is not a reply... assume additional patch
Assuming new revision: v3 ([cocci] [PATCH] ufs: Fix exception handling 
in ufs_fill_super())
Assuming new revision: v4 ([cocci] [PATCH] perf cputopo: Improve 
exception handling in build_cpu_topology())
Assuming new revision: v5 ([cocci] [PATCH] perf pmu: Improve exception 
handling in pmu_lookup())
Assuming new revision: v6 ([cocci] [PATCH] selftests/bpf: Improve 
exception handling in rbtree_add_and_remove())
Assuming new revision: v7 ([cocci] [PATCH resent] btrfs: Fix exception 
handling in relocating_repair_kthread())
Assuming new revision: v8 ([cocci] [PATCH resent] ufs: Fix exception 
handling in ufs_fill_super())
Assuming new revision: v9 ([cocci] [PATCH resent] perf cputopo: Improve 
exception handling in build_cpu_topology())
WARNING: duplicate messages found at index 1
    Subject 1: scsi: message: fusion: Return directly after input data 
validation failed in four functions
    Subject 2: btrfs: Fix exception handling in relocating_repair_kthread()
   2 is a reply... replacing existing: btrfs: Fix exception handling in 
relocating_repair_kthread()
WARNING: duplicate messages found at index 2
    Subject 1: scsi: message: fusion: Delete a redundant pointer check 
in four functions
    Subject 2: powerpc/4xx: Fix exception handling in 
ppc4xx_pciex_port_setup_hose()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 3
    Subject 1: scsi: message: fusion: Delete an unnecessary variable 
initialisation in four functions
    Subject 2: powerpc/4xx: Fix exception handling in 
ppc4xx_pciex_port_setup_hose()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: md/raid1: Fix exception handling in setup_conf()
    Subject 2: scsi: message: fusion: Return directly after input data 
validation failed in four functions
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 2
    Subject 1: md/raid10: Fix exception handling in setup_conf()
    Subject 2: scsi: message: fusion: Return directly after input data 
validation failed in four functions
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: irqchip/gic-v4: Fix exception handling in 
its_alloc_vcpu_irqs()
    Subject 2: md/raid1: Fix exception handling in setup_conf()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 2
    Subject 1: irqchip/gic-v4: Fix exception handling in 
its_alloc_vcpu_sgis()
    Subject 2: md/raid1: Fix exception handling in setup_conf()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: selinux: Improve exception handling in security_get_bools()
    Subject 2: irqchip/gic-v4: Fix exception handling in 
its_alloc_vcpu_irqs()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: selinux: Adjust implementation of security_get_bools()
    Subject 2: powerpc/4xx: Fix exception handling in 
ppc4xx_pciex_port_setup_hose()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: IB/uverbs: Improve exception handling in create_qp()
    Subject 2: selinux: Improve exception handling in security_get_bools()
   2 is a reply... replacing existing: selinux: Improve exception 
handling in security_get_bools()
WARNING: duplicate messages found at index 2
    Subject 1: IB/uverbs: Delete a duplicate check in create_qp()
    Subject 2: irqchip/gic-v4: Fix exception handling in 
its_alloc_vcpu_irqs()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: powerpc/pseries: Fix exception handling in 
pSeries_reconfig_add_node()
    Subject 2: IB/uverbs: Improve exception handling in create_qp()
   2 is not a reply... assume additional patch
Assuming new revision: v10 ([PATCH] ipvs: Fix exception handling in two 
functions)
Assuming new revision: v11 ([PATCH] selftests: cgroup: Fix exception 
handling in test_memcg_oom_group_score_events())
Assuming new revision: v12 ([Nouveau] [PATCH] drm/nouveau: Add a jump 
label in nouveau_gem_ioctl_pushbuf())
Assuming new revision: v13 ([PATCH] mm/mempolicy: Fix exception handling 
in shared_policy_replace())
Assuming new revision: v14 ([PATCH] firmware: ti_sci: Fix exception 
handling in ti_sci_probe())
Assuming new revision: v15 ([PATCH] remoteproc: imx_dsp_rproc: Improve 
exception handling in imx_dsp_rproc_mbox_alloc())
Assuming new revision: v16 ([PATCH] spi: atmel: Improve exception 
handling in atmel_spi_configure_dma())
WARNING: duplicate messages found at index 1
    Subject 1: powerpc/pseries: Do not pass an error pointer to 
of_node_put() in pSeries_reconfig_add_node()
    Subject 2: selinux: Adjust implementation of security_get_bools()
   2 is a reply... replacing existing: selinux: Adjust implementation of 
security_get_bools()
WARNING: duplicate messages found at index 2
    Subject 1: powerpc/pseries: Fix exception handling in 
pSeries_reconfig_add_node()
    Subject 2: powerpc/4xx: Fix exception handling in 
ppc4xx_pciex_port_setup_hose()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 1
    Subject 1: powerpc/pseries: Do not pass an error pointer to 
of_node_put() in pSeries_reconfig_add_node()
    Subject 2: powerpc/pseries: Do not pass an error pointer to 
of_node_put() in pSeries_reconfig_add_node()
   2 is not a reply... assume additional patch
WARNING: duplicate messages found at index 2
    Subject 1: powerpc/pseries: Fix exception handling in 
pSeries_reconfig_add_node()
    Subject 2: powerpc/pseries: Do not pass an error pointer to 
of_node_put() in pSeries_reconfig_add_node()
   2 is not a reply... assume additional patch
Will use the latest revision: v16
You can pick other revisions using the -vN flag
Checking attestation on all messages, may take a moment...
---
   ✗ [PATCH] spi: atmel: Improve exception handling in 
atmel_spi_configure_dma()
   ---
   ✗ BADSIG: DKIM/web.de
   ✓ Signed: DKIM/lists.infradead.org (From: Markus.Elfring@web.de)
---
Total patches: 1
---
Applying: spi: atmel: Improve exception handling in 
atmel_spi_configure_dma()



> ---
>   arch/powerpc/platforms/4xx/pci.c | 19 ++++++++++---------
>   1 file changed, 10 insertions(+), 9 deletions(-)
> 
> 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)
> --
> 2.40.0
>
Markus Elfring Oct. 3, 2024, 3:47 p.m. UTC | #2
> Looks like you have messed up your patches,

There were special communication settings involved which hindered desirable
data processing for known information systems.


> there is no much we can do it seems:
>
> $ b4 shazam e68a714b-32f2-de9f-066e-99a3f51a264f@web.de

Please take another look also at published information according to further
mailing list archive interfaces.

Example:
[PATCH v2 0/4] powerpc/4xx: Adjustments for four function implementations
https://lore.kernel.org/cocci/ecda8227-d89a-9c23-06b7-54f9d974af5e@web.de/
https://sympa.inria.fr/sympa/arc/cocci/2023-03/msg00079.html


Regards,
Markus
Christophe Leroy Oct. 3, 2024, 4:08 p.m. UTC | #3
Le 03/10/2024 à 17:47, Markus Elfring a écrit :
> …
>> Looks like you have messed up your patches,
> 
> There were special communication settings involved which hindered desirable
> data processing for known information systems.

Don't know what you mean.

> 
> 
>> there is no much we can do it seems:
>>
>> $ b4 shazam e68a714b-32f2-de9f-066e-99a3f51a264f@web.de
> 
> Please take another look also at published information according to further
> mailing list archive interfaces.

Another look to what ?

It seems like several patches were posted with the same Message-Id 
and/or with an unrelated In-Reply-To:

b4 is lost and cannot apply your series, it applies the patch at 
https://lore.kernel.org/all/82aebf6c-47ac-9d17-2d11-6245f582338e@web.de/

You may consider fixing and resending the series as an independant series.

Christophe
Markus Elfring Oct. 3, 2024, 4:38 p.m. UTC | #4
>>> Looks like you have messed up your patches,
>>
>> There were special communication settings involved which hindered desirable
>> data processing for known information systems.
>
> Don't know what you mean.

My email address was blocked in selected Linux mailing lists for a while.


>>> there is no much we can do it seems:
>>>
>>> $ b4 shazam e68a714b-32f2-de9f-066e-99a3f51a264f@web.de
>>
>> Please take another look also at published information according to further
>> mailing list archive interfaces.
>
> Another look to what ?
>
> It seems like several patches were posted with the same Message-Id and/or with an unrelated In-Reply-To:
>
> b4 is lost and cannot apply your series, it applies the patch at https://lore.kernel.org/all/82aebf6c-47ac-9d17-2d11-6245f582338e@web.de/
>
> You may consider fixing and resending the series as an independant series.
It seems that another information system did not get confused with published data.

Example:
[v2,1/4] powerpc/4xx: Fix exception handling in ppc4xx_pciex_port_setup_hose()
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/e68a714b-32f2-de9f-066e-99a3f51a264f@web.de/

Can we benefit any more from such information already?

Regards,
Markus
diff mbox series

Patch

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)