Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'kgdb-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux

Pull kgdb updates from Daniel Thompson:
"Two cleanups this cycle. The larger of which is the removal of a
private allocator within kdb and replacing it with regular memory
allocation. The other adopts the simplified version of strscpy() in a
couple of places in kdb"

* tag 'kgdb-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux:
kdb: Remove optional size arguments from strscpy() calls
kdb: remove usage of static environment buffer

+11 -43
+1 -1
include/linux/kdb.h
··· 104 104 #define KDB_NOENVVALUE (-6) 105 105 #define KDB_NOTIMP (-7) 106 106 #define KDB_ENVFULL (-8) 107 - #define KDB_ENVBUFFULL (-9) 107 + #define KDB_KMALLOCFAILED (-9) 108 108 #define KDB_TOOMANYBPT (-10) 109 109 #define KDB_TOOMANYDBREGS (-11) 110 110 #define KDB_DUPBPT (-12)
+2 -2
kernel/debug/kdb/kdb_io.c
··· 334 334 *cp = '\0'; 335 335 p_tmp = strrchr(buffer, ' '); 336 336 p_tmp = (p_tmp ? p_tmp + 1 : buffer); 337 - strscpy(tmpbuffer, p_tmp, sizeof(tmpbuffer)); 337 + strscpy(tmpbuffer, p_tmp); 338 338 *cp = tmp; 339 339 340 340 len = strlen(tmpbuffer); ··· 452 452 char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) 453 453 { 454 454 if (prompt && kdb_prompt_str != prompt) 455 - strscpy(kdb_prompt_str, prompt, CMD_BUFLEN); 455 + strscpy(kdb_prompt_str, prompt); 456 456 kdb_printf("%s", kdb_prompt_str); 457 457 kdb_nextline = 1; /* Prompt and input resets line number */ 458 458 return kdb_read(buffer, bufsize);
+8 -40
kernel/debug/kdb/kdb_main.c
··· 105 105 KDBMSG(NOENVVALUE, "Environment variable should have value"), 106 106 KDBMSG(NOTIMP, "Command not implemented"), 107 107 KDBMSG(ENVFULL, "Environment full"), 108 - KDBMSG(ENVBUFFULL, "Environment buffer full"), 108 + KDBMSG(KMALLOCFAILED, "Failed to allocate memory"), 109 109 KDBMSG(TOOMANYBPT, "Too many breakpoints defined"), 110 110 #ifdef CONFIG_CPU_XSCALE 111 111 KDBMSG(TOOMANYDBREGS, "More breakpoints than ibcr registers defined"), ··· 130 130 131 131 132 132 /* 133 - * Initial environment. This is all kept static and local to 134 - * this file. We don't want to rely on the memory allocation 135 - * mechanisms in the kernel, so we use a very limited allocate-only 136 - * heap for new and altered environment variables. The entire 137 - * environment is limited to a fixed number of entries (add more 138 - * to __env[] if required) and a fixed amount of heap (add more to 139 - * KDB_ENVBUFSIZE if required). 133 + * Initial environment. This is all kept static and local to this file. 134 + * The entire environment is limited to a fixed number of entries 135 + * (add more to __env[] if required) 140 136 */ 141 137 142 138 static char *__env[31] = { ··· 255 259 } 256 260 257 261 /* 258 - * kdballocenv - This function is used to allocate bytes for 259 - * environment entries. 260 - * Parameters: 261 - * bytes The number of bytes to allocate in the static buffer. 262 - * Returns: 263 - * A pointer to the allocated space in the buffer on success. 264 - * NULL if bytes > size available in the envbuffer. 265 - * Remarks: 266 - * We use a static environment buffer (envbuffer) to hold the values 267 - * of dynamically generated environment variables (see kdb_set). Buffer 268 - * space once allocated is never free'd, so over time, the amount of space 269 - * (currently 512 bytes) will be exhausted if env variables are changed 270 - * frequently. 271 - */ 272 - static char *kdballocenv(size_t bytes) 273 - { 274 - #define KDB_ENVBUFSIZE 512 275 - static char envbuffer[KDB_ENVBUFSIZE]; 276 - static int envbufsize; 277 - char *ep = NULL; 278 - 279 - if ((KDB_ENVBUFSIZE - envbufsize) >= bytes) { 280 - ep = &envbuffer[envbufsize]; 281 - envbufsize += bytes; 282 - } 283 - return ep; 284 - } 285 - 286 - /* 287 262 * kdbgetulenv - This function will return the value of an unsigned 288 263 * long-valued environment variable. 289 264 * Parameters: ··· 315 348 316 349 varlen = strlen(var); 317 350 vallen = strlen(val); 318 - ep = kdballocenv(varlen + vallen + 2); 319 - if (ep == (char *)0) 320 - return KDB_ENVBUFFULL; 351 + ep = kmalloc(varlen + vallen + 2, GFP_KDB); 352 + if (!ep) 353 + return KDB_KMALLOCFAILED; 321 354 322 355 sprintf(ep, "%s=%s", var, val); 323 356 ··· 326 359 && ((strncmp(__env[i], var, varlen) == 0) 327 360 && ((__env[i][varlen] == '\0') 328 361 || (__env[i][varlen] == '=')))) { 362 + kfree_const(__env[i]); 329 363 __env[i] = ep; 330 364 return 0; 331 365 }