Skip to contentSkip to conversation

kdb: remove usage of static environment buffer

PATCH In review Nir Lichtman 2 participants 2 messages Feb 4, 2025 – Feb 10, 2025 KGDB / KDB /debug_core

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kdb: remove usage of static environment buffer

Problem: The set environment variable logic uses a static "heap" like buffer to store the values of the variables, and they are never freed, on top of that this is redundant since the kernel supplies allocation facilities which are even used also in this file.

Solution: Remove the weird static buffer logic and use kmalloc instead, call kfree when overriding an existing variable.

---

v2: Fixes following Doug's CR - use kmalloc_const instead of kmalloc & rm redundant print in case of allocation error

 include/linux/kdb.h         |  2 +-
 kernel/debug/kdb/kdb_main.c | 48 +++++++------------------------------
 2 files changed, 9 insertions(+), 41 deletions(-)
include/linux/kdb.h +1 -1
index 905a2e2f45f6..ecbf819deeca 100644
@@ -104,7 +104,7 @@ extern int kdb_initial_cpu;
 #define KDB_NOENVVALUE	(-6)
 #define KDB_NOTIMP	(-7)
 #define KDB_ENVFULL	(-8)
-#define KDB_ENVBUFFULL	(-9)
+#define KDB_KMALLOCFAILED	(-9)
 #define KDB_TOOMANYBPT	(-10)
 #define KDB_TOOMANYDBREGS (-11)
 #define KDB_DUPBPT	(-12)
kernel/debug/kdb/kdb_main.c +8 -40

78 lines not on this page · raw message

Signature · 1 line
2.39.5
reviewer Reviewed-by on v2 1/1
#1 lore raw

Hi,

Quoted 10 lines · Nir Lichtman

Problem: The set environment variable logic uses a static "heap" like buffer to store the values of the variables, and they are never freed, on top of that this is redundant since the kernel supplies allocation facilities which are even used also in this file.

Solution: Remove the weird static buffer logic and use kmalloc instead, call kfree when overriding an existing variable.

Quoted 8 lines

---

v2: Fixes following Doug's CR - use kmalloc_const instead of kmalloc & rm redundant print in case of allocation error

 include/linux/kdb.h         |  2 +-
 kernel/debug/kdb/kdb_main.c | 48 +++++++------------------------------
 2 files changed, 9 insertions(+), 41 deletions(-)