Patchwork PPC Hardware Breakpoints: Fix incorrect pointer access

login
register
mail settings
Submitter Naveen N. Rao
Date July 6, 2012, 11:30 a.m.
Message ID <20120706113058.8600.30142.stgit@localhost.localdomain>
Download mbox | patch
Permalink /patch/169463/
State Accepted
Commit ac84aa2b3b9b791eac45174d1966d5fdf3bbba1c
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Naveen N. Rao - July 6, 2012, 11:30 a.m.
If arch_validate_hwbkpt_settings() fails, bp->ctx won't be valid and the
kernel panics. Add a check to fix this.

Reported-by: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/hw_breakpoint.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 2bc0584..f3a82dd 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -111,7 +111,7 @@  void arch_unregister_hw_breakpoint(struct perf_event *bp)
 	 * and the single_step_dabr_instruction(), then cleanup the breakpoint
 	 * restoration variables to prevent dangling pointers.
 	 */
-	if (bp->ctx->task)
+	if (bp->ctx && bp->ctx->task)
 		bp->ctx->task->thread.last_hit_ubp = NULL;
 }