From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask
Date: Tue, 12 Jan 2016 17:23:12 +0800 [thread overview]
Message-ID: <1452590592-15921-1-git-send-email-van.freenix@gmail.com> (raw)
From: Peng Fan <peng.fan@nxp.com>
We should use ARRAY_SIZE, but not sizeof. The size of
env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
If using 16 as the end condition, we may access memory that
not belong to array env_flags_varaccess_mask.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: York Sun <yorksun@freescale.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
common/env_flags.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/env_flags.c b/common/env_flags.c
index 7719355..9c3aed1 100644
--- a/common/env_flags.c
+++ b/common/env_flags.c
@@ -152,7 +152,7 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
{
int i;
- for (i = 0; i < sizeof(env_flags_varaccess_mask); i++)
+ for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++)
if (env_flags_varaccess_mask[i] ==
(binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
return (enum env_flags_varaccess)i;
--
2.6.2
next reply other threads:[~2016-01-12 9:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 9:23 Peng Fan [this message]
2016-01-13 20:09 ` [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask Simon Glass
2016-01-13 20:39 ` Joe Hershberger
2016-01-14 13:22 ` [U-Boot] " Tom Rini
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=1452590592-15921-1-git-send-email-van.freenix@gmail.com \
--to=van.freenix@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