diff mbox series

env: correct overflow check of env_has_init size

Message ID 20200624072726.24386-1-patrick.delaunay@st.com
State Accepted
Commit d5a6a5a9271bd93d0c8337788ddaac708c9123ee
Headers show
Series env: correct overflow check of env_has_init size | expand

Commit Message

Patrick Delaunay June 24, 2020, 7:27 a.m. UTC
Correct the overflow check of the bit-field env_has_init with
the max value of env_location= ENVL_COUNT and no more with the
size of env_locations.

This bit-field is indexed by this enumerate and not by the position in
the env_locations (only used in env_get_location) and the
2 values are different, depending of thea ctivated CONFIG_ENV_IS_ options.

Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
---

 env/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini July 27, 2020, 1:32 p.m. UTC | #1
On Wed, Jun 24, 2020 at 09:27:25AM +0200, Patrick Delaunay wrote:

> Correct the overflow check of the bit-field env_has_init with

> the max value of env_location= ENVL_COUNT and no more with the

> size of env_locations.

> 

> This bit-field is indexed by this enumerate and not by the position in

> the env_locations (only used in env_get_location) and the

> 2 values are different, depending of thea ctivated CONFIG_ENV_IS_ options.

> 

> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>


Applied to u-boot/master, thanks!

-- 
Tom
diff mbox series

Patch

diff --git a/env/env.c b/env/env.c
index dcc25c030b..49545a8d9c 100644
--- a/env/env.c
+++ b/env/env.c
@@ -103,7 +103,7 @@  static void env_set_inited(enum env_location location)
 	 * using the above enum value as the bit index. We need to
 	 * make sure that we're not overflowing it.
 	 */
-	BUILD_BUG_ON(ARRAY_SIZE(env_locations) > BITS_PER_LONG);
+	BUILD_BUG_ON(ENVL_COUNT > BITS_PER_LONG);
 
 	gd->env_has_init |= BIT(location);
 }