From: Yao Cheng Date: Wed, 10 Aug 2011 07:11:16 +0000 (+0800) Subject: MIPS: mips32: fix wrong loop bound in flush_cache() X-Git-Tag: v2011.09-rc1~69 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dc344589ded4fb4d63ba7f0cdf670e2ffcf5e5a0;p=oweals%2Fu-boot.git MIPS: mips32: fix wrong loop bound in flush_cache() The issue is found when calling flush_cache() with zero "size" argument. The bound of loop is miscalculated in this case and flush_cache() enters a wrong flushing loop. Signed-off-by: Yao Cheng Cc: Shinya Kuribayashi Cc: Sergei Shtylyov Cc: Mike Frysinger Signed-off-by: Shinya Kuribayashi --- diff --git a/arch/mips/cpu/mips32/cpu.c b/arch/mips/cpu/mips32/cpu.c index 3ae397c8ef..7b49e1b612 100644 --- a/arch/mips/cpu/mips32/cpu.c +++ b/arch/mips/cpu/mips32/cpu.c @@ -56,6 +56,10 @@ void flush_cache(ulong start_addr, ulong size) unsigned long addr = start_addr & ~(lsize - 1); unsigned long aend = (start_addr + size - 1) & ~(lsize - 1); + /* aend will be miscalculated when size is zero, so we return here */ + if (size == 0) + return; + while (1) { cache_op(Hit_Writeback_Inv_D, addr); cache_op(Hit_Invalidate_I, addr);