kdb: remove usage of static environment buffer
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
@@ -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
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.
Signed-off-by Nir Lichtman <[email protected]>
Quoted 8 lines
---
v2: Fixes following Doug's CR - use
kmalloc_constinstead of kmalloc & rm redundant print in case of allocation errorinclude/linux/kdb.h | 2 +- kernel/debug/kdb/kdb_main.c | 48 +++++++------------------------------ 2 files changed, 9 insertions(+), 41 deletions(-)