hw_breakpoints, powerpc: Fix CONFIG_HAVE_HW_BREAKPOINT off-case in ptrace_set_debugreg()

We make use of ptrace_get_breakpoints() / ptrace_put_breakpoints() to
protect ptrace_set_debugreg() even if CONFIG_HAVE_HW_BREAKPOINT if off.
However in this case, these APIs are not implemented.

To fix this, push the protection down inside the relevant ifdef.
Best would be to export the code inside
CONFIG_HAVE_HW_BREAKPOINT into a standalone function to cleanup
the ifdefury there and call the breakpoint ref API inside. But
as it is more invasive, this should be rather made in an -rc1.

Fixes this build error:

arch/powerpc/kernel/ptrace.c:1594: error: implicit declaration of function 'ptrace_get_breakpoints' make[2]: ***

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: LPPC <linuxppc-dev@lists.ozlabs.org>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: v2.6.33.. <stable@kernel.org>
Link: http://lkml.kernel.org/r/1304639598-4707-1-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Frederic Weisbecker and committed by Ingo Molnar 925f83c0 4d70230b

+11 -4
+11 -4
arch/powerpc/kernel/ptrace.c
··· 933 933 if (data && !(data & DABR_TRANSLATION)) 934 934 return -EIO; 935 935 #ifdef CONFIG_HAVE_HW_BREAKPOINT 936 + if (ptrace_get_breakpoints(task) < 0) 937 + return -ESRCH; 938 + 936 939 bp = thread->ptrace_bps[0]; 937 940 if ((!data) || !(data & (DABR_DATA_WRITE | DABR_DATA_READ))) { 938 941 if (bp) { 939 942 unregister_hw_breakpoint(bp); 940 943 thread->ptrace_bps[0] = NULL; 941 944 } 945 + ptrace_put_breakpoints(task); 942 946 return 0; 943 947 } 944 948 if (bp) { ··· 952 948 (DABR_DATA_WRITE | DABR_DATA_READ), 953 949 &attr.bp_type); 954 950 ret = modify_user_hw_breakpoint(bp, &attr); 955 - if (ret) 951 + if (ret) { 952 + ptrace_put_breakpoints(task); 956 953 return ret; 954 + } 957 955 thread->ptrace_bps[0] = bp; 956 + ptrace_put_breakpoints(task); 958 957 thread->dabr = data; 959 958 return 0; 960 959 } ··· 972 965 ptrace_triggered, task); 973 966 if (IS_ERR(bp)) { 974 967 thread->ptrace_bps[0] = NULL; 968 + ptrace_put_breakpoints(task); 975 969 return PTR_ERR(bp); 976 970 } 971 + 972 + ptrace_put_breakpoints(task); 977 973 978 974 #endif /* CONFIG_HAVE_HW_BREAKPOINT */ 979 975 ··· 1601 1591 } 1602 1592 1603 1593 case PTRACE_SET_DEBUGREG: 1604 - if (ptrace_get_breakpoints(child) < 0) 1605 - return -ESRCH; 1606 1594 ret = ptrace_set_debugreg(child, addr, data); 1607 - ptrace_put_breakpoints(child); 1608 1595 break; 1609 1596 1610 1597 #ifdef CONFIG_PPC64