]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
powerpc/powernv/pci: fix iterator signedness
authorAndrzej Hajda <a.hajda@samsung.com>
Wed, 17 Aug 2016 10:03:05 +0000 (12:03 +0200)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 22 Aug 2016 01:09:33 +0000 (11:09 +1000)
Unsigned type is always non-negative, so the loop could not end in case
condition is never true.

The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/powernv/pci-ioda.c

index fd9444f9fb0c24e0ed02dcb722c0e824ddc218e2..13218263e66ec7cdd9b29454fc82d734e80ec7b8 100644 (file)
@@ -149,7 +149,7 @@ static void pnv_ioda_reserve_pe(struct pnv_phb *phb, int pe_no)
 
 static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb)
 {
-       unsigned long pe = phb->ioda.total_pe_num - 1;
+       long pe;
 
        for (pe = phb->ioda.total_pe_num - 1; pe >= 0; pe--) {
                if (!test_and_set_bit(pe, phb->ioda.pe_alloc))