Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb:
kgdb,ppc: Fix regression in evr register handling
kgdb,x86: fix regression in detach handling
kdb: fix crash when KDB_BASE_CMD_MAX is exceeded
kdb: fix memory leak in kdb_main.c

+21 -16
+2 -2
arch/powerpc/kernel/kgdb.c
··· 337 337 /* FP registers 32 -> 63 */ 338 338 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) 339 339 if (current) 340 - memcpy(mem, current->thread.evr[regno-32], 340 + memcpy(mem, &current->thread.evr[regno-32], 341 341 dbg_reg_def[regno].size); 342 342 #else 343 343 /* fp registers not used by kernel, leave zero */ ··· 362 362 if (regno >= 32 && regno < 64) { 363 363 /* FP registers 32 -> 63 */ 364 364 #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) 365 - memcpy(current->thread.evr[regno-32], mem, 365 + memcpy(&current->thread.evr[regno-32], mem, 366 366 dbg_reg_def[regno].size); 367 367 #else 368 368 /* fp registers not used by kernel, leave zero */
+8 -4
arch/x86/kernel/kgdb.c
··· 315 315 if (!breakinfo[i].enabled) 316 316 continue; 317 317 bp = *per_cpu_ptr(breakinfo[i].pev, cpu); 318 - if (bp->attr.disabled == 1) 318 + if (!bp->attr.disabled) { 319 + arch_uninstall_hw_breakpoint(bp); 320 + bp->attr.disabled = 1; 319 321 continue; 322 + } 320 323 if (dbg_is_early) 321 324 early_dr7 &= ~encode_dr7(i, breakinfo[i].len, 322 325 breakinfo[i].type); 323 - else 324 - arch_uninstall_hw_breakpoint(bp); 325 - bp->attr.disabled = 1; 326 + else if (hw_break_release_slot(i)) 327 + printk(KERN_ERR "KGDB: hw bpt remove failed %lx\n", 328 + breakinfo[i].addr); 329 + breakinfo[i].enabled = 0; 326 330 } 327 331 } 328 332
+11 -10
kernel/debug/kdb/kdb_main.c
··· 82 82 #define for_each_kdbcmd(cmd, num) \ 83 83 for ((cmd) = kdb_base_commands, (num) = 0; \ 84 84 num < kdb_max_commands; \ 85 - num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++, num++) 85 + num++, num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++) 86 86 87 87 typedef struct _kdbmsg { 88 88 int km_diag; /* kdb diagnostic */ ··· 646 646 } 647 647 if (!s->usable) 648 648 return KDB_NOTIMP; 649 - s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB); 649 + s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB); 650 650 if (!s->command) { 651 651 kdb_printf("Could not allocate new kdb_defcmd table for %s\n", 652 652 cmdstr); ··· 2361 2361 */ 2362 2362 static int kdb_ll(int argc, const char **argv) 2363 2363 { 2364 - int diag; 2364 + int diag = 0; 2365 2365 unsigned long addr; 2366 2366 long offset = 0; 2367 2367 unsigned long va; ··· 2400 2400 char buf[80]; 2401 2401 2402 2402 if (KDB_FLAG(CMD_INTERRUPT)) 2403 - return 0; 2403 + goto out; 2404 2404 2405 2405 sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); 2406 2406 diag = kdb_parse(buf); 2407 2407 if (diag) 2408 - return diag; 2408 + goto out; 2409 2409 2410 2410 addr = va + linkoffset; 2411 2411 if (kdb_getword(&va, addr, sizeof(va))) 2412 - return 0; 2412 + goto out; 2413 2413 } 2414 - kfree(command); 2415 2414 2416 - return 0; 2415 + out: 2416 + kfree(command); 2417 + return diag; 2417 2418 } 2418 2419 2419 2420 static int kdb_kgdb(int argc, const char **argv) ··· 2740 2739 } 2741 2740 if (kdb_commands) { 2742 2741 memcpy(new, kdb_commands, 2743 - kdb_max_commands * sizeof(*new)); 2742 + (kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new)); 2744 2743 kfree(kdb_commands); 2745 2744 } 2746 2745 memset(new + kdb_max_commands, 0, 2747 2746 kdb_command_extend * sizeof(*new)); 2748 2747 kdb_commands = new; 2749 - kp = kdb_commands + kdb_max_commands; 2748 + kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX; 2750 2749 kdb_max_commands += kdb_command_extend; 2751 2750 } 2752 2751