[tip:x86/pti] x86/ptrace: Fix questionable code pattern

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  41f0e758b428a50c26458848ba15d7e2a2c97d0f
Gitweb:     https://git.kernel.org/tip/41f0e758b428a50c26458848ba15d7e2a2c97d0f
Author:     Ingo Molnar <mingo@xxxxxxxxxx>
AuthorDate: Fri, 28 Jun 2019 11:13:12 +0200
Committer:  Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Fri, 28 Jun 2019 11:17:05 +0200

x86/ptrace: Fix questionable code pattern

The following commit:

  31a2fbb390fe: ("x86/ptrace: Fix possible spectre-v1 in ptrace_get_debugreg()")

triggers this build warning:

  arch/x86/kernel/ptrace.c:612:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

the code looks correct, but the code pattern is of course bogus, so fix it.

Cc: Dianzhang Chen <dianzhangchen0@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: bp@xxxxxxxxx
Cc: hpa@xxxxxxxxx
Cc: stable@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
 arch/x86/kernel/ptrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index cbac64659dc4..ef13511aca7d 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -643,13 +643,14 @@ restore:
 static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
 {
 	struct thread_struct *thread = &tsk->thread;
+	struct perf_event *bp;
 	unsigned long val = 0;
 	int index = n;
 
 	if (n < HBP_NUM) {
 		index = array_index_nospec(index, HBP_NUM);
-		struct perf_event *bp = thread->ptrace_bps[index];
 
+		bp = thread->ptrace_bps[index];
 		if (bp)
 			val = bp->hw.info.address;
 	} else if (n == 6) {



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux