From: Yao Cheng <saturdaycoder@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] Fix wrong loop bound in flush_cache() when "size" is zero
Date: Mon, 8 Aug 2011 21:57:58 +0800 [thread overview]
Message-ID: <1312811878-4535-1-git-send-email-saturdaycoder@gmail.com> (raw)
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.
To fix this issue I skipped the operations when "size" is found to be zero.
Signed-off-by: Yao Cheng <saturdaycoder@gmail.com>
Cc: Shinya Kuribayashi<skuribay@pobox.com>
---
Changes for v2:
- Coding style cleanup
- Move code after declarations to avoid warning
arch/mips/cpu/mips32/cpu.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/mips/cpu/mips32/cpu.c b/arch/mips/cpu/mips32/cpu.c
index 3ae397c..8fa53ba 100644
--- a/arch/mips/cpu/mips32/cpu.c
+++ b/arch/mips/cpu/mips32/cpu.c
@@ -56,6 +56,11 @@ 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);
--
1.7.4.1
next reply other threads:[~2011-08-08 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-08 13:57 Yao Cheng [this message]
2011-08-08 18:47 ` [U-Boot] [PATCH v2] Fix wrong loop bound in flush_cache() when "size" is zero Mike Frysinger
2011-08-09 12:38 ` Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312811878-4535-1-git-send-email-saturdaycoder@gmail.com \
--to=saturdaycoder@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox