From: Sergei Shtylyov <sshtylyov@mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Fix wrong loop bound in flush_cache() when "size" is zero.
Date: Mon, 08 Aug 2011 16:23:09 +0400 [thread overview]
Message-ID: <4E3FD52D.7090709@mvista.com> (raw)
In-Reply-To: <1312790868-8959-1-git-send-email-saturdaycoder@gmail.com>
Hello.
On 08-08-2011 12:07, Yao Cheng wrote:
> 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>
> ---
> 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..1bf0094 100644
> --- a/arch/mips/cpu/mips32/cpu.c
> +++ b/arch/mips/cpu/mips32/cpu.c
> @@ -52,6 +52,11 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>
> void flush_cache(ulong start_addr, ulong size)
> {
> + /* aend will be miscalculated when size is zero, so we need return here */
> + if (size == 0) {
> + return;
> + }
> +
Please indent with tabs, not spaces. Also, doesn't this code generate
warning (code before declarations)?
> unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE;
> unsigned long addr = start_addr& ~(lsize - 1);
> unsigned long aend = (start_addr + size - 1)& ~(lsize - 1);
WBR, Sergei
next prev parent reply other threads:[~2011-08-08 12:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-08 8:07 [U-Boot] [PATCH] Fix wrong loop bound in flush_cache() when "size" is zero Yao Cheng
2011-08-08 12:23 ` Sergei Shtylyov [this message]
2011-08-08 13:55 ` Saturday Coder
2011-08-08 20:04 ` Scott Wood
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=4E3FD52D.7090709@mvista.com \
--to=sshtylyov@mvista.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.