]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
kirkwood: mpp: fix possible endless loop in kirkwood_mpp_conf()
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 24 Aug 2017 07:16:50 +0000 (09:16 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 24 Aug 2017 07:16:50 +0000 (09:16 +0200)
Using 'continue' in a loop is fatal if the last statement in the loop
increments the loop index.
Modify the loop to always increment the loop index (list pointer in
this case).

arch/arm/cpu/arm926ejs/kirkwood/mpp.c

index 03eb2de520f72bbf555d62fd643c6bc7151d061f..9bcaa90f3ff19a6aa6d3252d2bbed063da0f1372 100644 (file)
@@ -50,8 +50,9 @@ void kirkwood_mpp_conf(u32 *mpp_list, u32 *mpp_save)
 
 
        while (*mpp_list) {
-               unsigned int num = MPP_NUM(*mpp_list);
-               unsigned int sel = MPP_SEL(*mpp_list);
+               u32 mpp = *mpp_list++;
+               unsigned int num = MPP_NUM(mpp);
+               unsigned int sel = MPP_SEL(mpp);
                unsigned int sel_save;
                int shift;
 
@@ -60,7 +61,7 @@ void kirkwood_mpp_conf(u32 *mpp_list, u32 *mpp_save)
                                        "number (%u)\n", num);
                        continue;
                }
-               if (!(*mpp_list & variant_mask)) {
+               if (!(mpp & variant_mask)) {
                        debug("kirkwood_mpp_conf: requested MPP%u config "
                                "unavailable on this hardware\n", num);
                        continue;
@@ -76,8 +77,6 @@ void kirkwood_mpp_conf(u32 *mpp_list, u32 *mpp_save)
 
                mpp_ctrl[num / 8] &= ~(0xf << shift);
                mpp_ctrl[num / 8] |= sel << shift;
-
-               mpp_list++;
        }
 
        debug("  final MPP regs:");