diff mbox series

firenze-pci: Fix infinite loop in firenze_pci_add_loc_code()

Message ID 20200226052934.9221-1-oohall@gmail.com
State Accepted
Headers show
Series firenze-pci: Fix infinite loop in firenze_pci_add_loc_code() | expand

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (f123417068e51842004bdc047c8c5107b70442ef)

Commit Message

Oliver O'Halloran Feb. 26, 2020, 5:29 a.m. UTC
If ibm,slot-location-code isn't in a PCI device's parent node the loop
to search for it will never terminate since p = np->parent is always
going to return the same result.

Fixes: ab1b05d29f5e ("PCI: create optional loc-code platform callback")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 platforms/ibm-fsp/firenze-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Klaus Heinrich Kiwi Feb. 27, 2020, 11:46 a.m. UTC | #1
On 2/26/2020 2:29 AM, Oliver O'Halloran wrote:

>   	 */
> -	for (p = np->parent; p; p = np->parent) {
> +	for (p = np->parent; p; p = p->parent) {
>   		blcode = dt_prop_get_def(p, "ibm,slot-location-code", NULL);

Good catch!

I should have seen it the first time..

  -Klaus
Oliver O'Halloran Feb. 27, 2020, 12:25 p.m. UTC | #2
On Thu, Feb 27, 2020 at 10:46 PM Klaus Heinrich Kiwi
<klaus@linux.vnet.ibm.com> wrote:
>
>
>
> On 2/26/2020 2:29 AM, Oliver O'Halloran wrote:
>
> >        */
> > -     for (p = np->parent; p; p = np->parent) {
> > +     for (p = np->parent; p; p = p->parent) {
> >               blcode = dt_prop_get_def(p, "ibm,slot-location-code", NULL);
>
> Good catch!

Less of a catch and more blundering into it after It bricked my Tuleta :(

> I should have seen it the first time..
>
>   -Klaus

I should probably not tell people to use bad code, oh well.
Oliver O'Halloran March 6, 2020, 3:32 a.m. UTC | #3
On Wed, Feb 26, 2020 at 4:29 PM Oliver O'Halloran <oohall@gmail.com> wrote:
>
> If ibm,slot-location-code isn't in a PCI device's parent node the loop
> to search for it will never terminate since p = np->parent is always
> going to return the same result.
>
> Fixes: ab1b05d29f5e ("PCI: create optional loc-code platform callback")
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Merged as 82aed17a5468aff6b600ee1694a10a60f942c018
diff mbox series

Patch

diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c
index efbe5525da4b..12e0e98991aa 100644
--- a/platforms/ibm-fsp/firenze-pci.c
+++ b/platforms/ibm-fsp/firenze-pci.c
@@ -987,7 +987,7 @@  void firenze_pci_add_loc_code(struct dt_node *np, struct pci_device *pd)
 	 * prefer fully-qualified slot-location-code, walk-up parent tree
 	 * to find one
 	 */
-	for (p = np->parent; p; p = np->parent) {
+	for (p = np->parent; p; p = p->parent) {
 		blcode = dt_prop_get_def(p, "ibm,slot-location-code", NULL);
 		if (blcode)
 			break;