From: Lothar Waßmann Date: Thu, 24 Aug 2017 07:16:50 +0000 (+0200) Subject: kirkwood: mpp: fix possible endless loop in kirkwood_mpp_conf() X-Git-Tag: KARO-TK71-2017-08-24~2 X-Git-Url: https://git.karo-electronics.de/?p=karo-tx-uboot.git;a=commitdiff_plain;h=6af5a1ce5bc014a8375be44a77ddd35d2721d20a kirkwood: mpp: fix possible endless loop in kirkwood_mpp_conf() 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). --- diff --git a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c index 03eb2de520..9bcaa90f3f 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c @@ -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:");