Commit 2d42dc3f authored by Linus Torvalds's avatar Linus Torvalds

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
parents 70b99eff e3839ed8
...@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) ...@@ -337,7 +337,7 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
/* FP registers 32 -> 63 */ /* FP registers 32 -> 63 */
#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
if (current) if (current)
memcpy(mem, current->thread.evr[regno-32], memcpy(mem, &current->thread.evr[regno-32],
dbg_reg_def[regno].size); dbg_reg_def[regno].size);
#else #else
/* fp registers not used by kernel, leave zero */ /* fp registers not used by kernel, leave zero */
...@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) ...@@ -362,7 +362,7 @@ int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
if (regno >= 32 && regno < 64) { if (regno >= 32 && regno < 64) {
/* FP registers 32 -> 63 */ /* FP registers 32 -> 63 */
#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE) #if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_SPE)
memcpy(current->thread.evr[regno-32], mem, memcpy(&current->thread.evr[regno-32], mem,
dbg_reg_def[regno].size); dbg_reg_def[regno].size);
#else #else
/* fp registers not used by kernel, leave zero */ /* fp registers not used by kernel, leave zero */
......
...@@ -315,14 +315,18 @@ static void kgdb_remove_all_hw_break(void) ...@@ -315,14 +315,18 @@ static void kgdb_remove_all_hw_break(void)
if (!breakinfo[i].enabled) if (!breakinfo[i].enabled)
continue; continue;
bp = *per_cpu_ptr(breakinfo[i].pev, cpu); bp = *per_cpu_ptr(breakinfo[i].pev, cpu);
if (bp->attr.disabled == 1) if (!bp->attr.disabled) {
arch_uninstall_hw_breakpoint(bp);
bp->attr.disabled = 1;
continue; continue;
}
if (dbg_is_early) if (dbg_is_early)
early_dr7 &= ~encode_dr7(i, breakinfo[i].len, early_dr7 &= ~encode_dr7(i, breakinfo[i].len,
breakinfo[i].type); breakinfo[i].type);
else else if (hw_break_release_slot(i))
arch_uninstall_hw_breakpoint(bp); printk(KERN_ERR "KGDB: hw bpt remove failed %lx\n",
bp->attr.disabled = 1; breakinfo[i].addr);
breakinfo[i].enabled = 0;
} }
} }
......
...@@ -82,7 +82,7 @@ static kdbtab_t kdb_base_commands[50]; ...@@ -82,7 +82,7 @@ static kdbtab_t kdb_base_commands[50];
#define for_each_kdbcmd(cmd, num) \ #define for_each_kdbcmd(cmd, num) \
for ((cmd) = kdb_base_commands, (num) = 0; \ for ((cmd) = kdb_base_commands, (num) = 0; \
num < kdb_max_commands; \ num < kdb_max_commands; \
num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++, num++) num++, num == KDB_BASE_CMD_MAX ? cmd = kdb_commands : cmd++)
typedef struct _kdbmsg { typedef struct _kdbmsg {
int km_diag; /* kdb diagnostic */ int km_diag; /* kdb diagnostic */
...@@ -646,7 +646,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0) ...@@ -646,7 +646,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
} }
if (!s->usable) if (!s->usable)
return KDB_NOTIMP; return KDB_NOTIMP;
s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB); s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
if (!s->command) { if (!s->command) {
kdb_printf("Could not allocate new kdb_defcmd table for %s\n", kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
cmdstr); cmdstr);
...@@ -2361,7 +2361,7 @@ static int kdb_pid(int argc, const char **argv) ...@@ -2361,7 +2361,7 @@ static int kdb_pid(int argc, const char **argv)
*/ */
static int kdb_ll(int argc, const char **argv) static int kdb_ll(int argc, const char **argv)
{ {
int diag; int diag = 0;
unsigned long addr; unsigned long addr;
long offset = 0; long offset = 0;
unsigned long va; unsigned long va;
...@@ -2400,20 +2400,21 @@ static int kdb_ll(int argc, const char **argv) ...@@ -2400,20 +2400,21 @@ static int kdb_ll(int argc, const char **argv)
char buf[80]; char buf[80];
if (KDB_FLAG(CMD_INTERRUPT)) if (KDB_FLAG(CMD_INTERRUPT))
return 0; goto out;
sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
diag = kdb_parse(buf); diag = kdb_parse(buf);
if (diag) if (diag)
return diag; goto out;
addr = va + linkoffset; addr = va + linkoffset;
if (kdb_getword(&va, addr, sizeof(va))) if (kdb_getword(&va, addr, sizeof(va)))
return 0; goto out;
} }
kfree(command);
return 0; out:
kfree(command);
return diag;
} }
static int kdb_kgdb(int argc, const char **argv) static int kdb_kgdb(int argc, const char **argv)
...@@ -2739,13 +2740,13 @@ int kdb_register_repeat(char *cmd, ...@@ -2739,13 +2740,13 @@ int kdb_register_repeat(char *cmd,
} }
if (kdb_commands) { if (kdb_commands) {
memcpy(new, kdb_commands, memcpy(new, kdb_commands,
kdb_max_commands * sizeof(*new)); (kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new));
kfree(kdb_commands); kfree(kdb_commands);
} }
memset(new + kdb_max_commands, 0, memset(new + kdb_max_commands, 0,
kdb_command_extend * sizeof(*new)); kdb_command_extend * sizeof(*new));
kdb_commands = new; kdb_commands = new;
kp = kdb_commands + kdb_max_commands; kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX;
kdb_max_commands += kdb_command_extend; kdb_max_commands += kdb_command_extend;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment