summaryrefslogtreecommitdiff
path: root/lib/hashtable.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2024-12-09 08:46:57 -0600
committerTom Rini <trini@konsulko.com>2024-12-09 08:46:57 -0600
commit9dd0a9ecaa539adb99f74ea5cebcafcdebe93aad (patch)
tree275308e9fd137acde53d74c8d5170a21cbeb9cd4 /lib/hashtable.c
parent39759bf9fe3a5b6d4788164fc046f5f8aee5cbff (diff)
parent1c9fe756edba755679e8e4dc525d12e7deda3808 (diff)
Merge tag 'u-boot-imx-next-20241209' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx into next
CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/23736 - Add support for the NXP i.MX91 EVK board. - Improve EEPRON suport on i.MX8MP DHCOM board. - Switch phycore_imx8mm to using environment text files and improve environment handling.
Diffstat (limited to 'lib/hashtable.c')
-rw-r--r--lib/hashtable.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/hashtable.c b/lib/hashtable.c
index e8a59e2dcac..75c263b5053 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -221,11 +221,32 @@ static int
do_callback(const struct env_entry *e, const char *name, const char *value,
enum env_op op, int flags)
{
+ int ret = 0;
+
#ifndef CONFIG_XPL_BUILD
- if (e->callback)
- return e->callback(name, value, op, flags);
+ static bool in_callback;
+
+ if (!e->callback || in_callback)
+ return 0;
+
+ /*
+ * In case there are two variables which each implement env callback
+ * that performs env_set() on the other variable, the callbacks will
+ * call each other recursively until the stack runs out. Prevent such
+ * a recursion from happening.
+ *
+ * Example which triggers this behavior:
+ * static int on_foo(...) { env_set("bar", 0); ... }
+ * static int on_bar(...) { env_set("foo", 0); ... }
+ * U_BOOT_ENV_CALLBACK(foo, on_foo);
+ * U_BOOT_ENV_CALLBACK(bar, on_bar);
+ */
+ in_callback = true;
+ ret = e->callback(name, value, op, flags);
+ in_callback = false;
#endif
- return 0;
+
+ return ret;
}
/*