common: env_flags: fix loop condition when using env_flags_varaccess_mask
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> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
bb08a6e7d5
commit
db18f548cb
|
@ -152,7 +152,7 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
|
||||||
{
|
{
|
||||||
int i;
|
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] ==
|
if (env_flags_varaccess_mask[i] ==
|
||||||
(binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
|
(binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
|
||||||
return (enum env_flags_varaccess)i;
|
return (enum env_flags_varaccess)i;
|
||||||
|
|
Loading…
Reference in New Issue