All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH] u-boot: remove driver lookup loop from env_save()
@ 2018-07-10 12:57 Nicholas Faustini
  2018-07-10 20:49 ` Simon Glass
  0 siblings, 1 reply; 16+ messages in thread
From: Nicholas Faustini @ 2018-07-10 12:57 UTC (permalink / raw)
  To: u-boot

When called with ENVOP_SAVE, env_get_location() only returns the
gd->env_load_location variable without actually checking for
the environment location and priority. This allows saving the
environment into the same location that has been previously loaded.

This behaviour causes env_save() to fall into an infinite loop when
the low-level drv->save() call fails.

The env_save() function should not loop through the environment
location list but it should use the previously discovered
environment driver once.

Signed-off-by: Nicholas Faustini <nicholas.faustini@azcomtech.com>
---

 env/env.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/env/env.c b/env/env.c
index 5c0842a..897d197 100644
--- a/env/env.c
+++ b/env/env.c
@@ -211,16 +211,16 @@ int env_load(void)
 int env_save(void)
 {
 	struct env_driver *drv;
-	int prio;
 
-	for (prio = 0; (drv = env_driver_lookup(ENVOP_SAVE, prio)); prio++) {
+	drv = env_driver_lookup(ENVOP_SAVE, 0);
+	if (drv) {
 		int ret;
 
 		if (!drv->save)
-			continue;
+			return -ENODEV;
 
 		if (!env_has_inited(drv->location))
-			continue;
+			return -ENODEV;
 
 		printf("Saving Environment to %s... ", drv->name);
 		ret = drv->save();
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-07-17  4:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-10 12:57 [U-Boot] [RFC PATCH] u-boot: remove driver lookup loop from env_save() Nicholas Faustini
2018-07-10 20:49 ` Simon Glass
2018-07-11  4:57   ` Simon Goldschmidt
2018-07-11  5:09   ` Simon Goldschmidt
2018-07-11  8:33     ` Nicholas
2018-07-11  9:48       ` Maxime Ripard
2018-07-11 10:01         ` Simon Goldschmidt
2018-07-11 10:44           ` Nicholas
2018-07-11 13:50             ` Maxime Ripard
2018-07-12  7:02               ` Simon Goldschmidt
2018-07-12  7:20                 ` Maxime Ripard
2018-07-17  4:48                   ` Simon Goldschmidt
2018-07-11 10:49         ` Wolfgang Denk
2018-07-11 13:47           ` Maxime Ripard
2018-07-11 13:54             ` Wolfgang Denk
2018-07-11  7:37   ` Lukasz Majewski

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.