[tip: x86/asm] x86/tls: Clean up 'sel' variable usage in do_set_thread_area()

tip-bot2 for Uros Bizjak posted 1 patch 1 day, 3 hours ago
arch/x86/kernel/tls.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[tip: x86/asm] x86/tls: Clean up 'sel' variable usage in do_set_thread_area()
Posted by tip-bot2 for Uros Bizjak 1 day, 3 hours ago
The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     3b19e22cffe61bcdf10ee5e7584cfa3c1c54dc92
Gitweb:        https://git.kernel.org/tip/3b19e22cffe61bcdf10ee5e7584cfa3c1c54dc92
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 30 Mar 2026 10:59:23 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 31 Mar 2026 09:50:11 +02:00

x86/tls: Clean up 'sel' variable usage in do_set_thread_area()

The top-level 'sel' variable in do_set_thread_area() was previously
marked __maybe_unused, but it is now only needed locally when
updating the current task.

Remove the unused top-level declaration and introduce a local 'sel'
variable where it is actually used

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/20260330085938.67985-4-ubizjak@gmail.com
---
 arch/x86/kernel/tls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 3ffbab0..86b4186 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -117,7 +117,7 @@ int do_set_thread_area(struct task_struct *p, int idx,
 		       int can_allocate)
 {
 	struct user_desc info;
-	unsigned short __maybe_unused sel, modified_sel;
+	unsigned short modified_sel;
 
 	if (copy_from_user(&info, u_info, sizeof(info)))
 		return -EFAULT;
@@ -153,6 +153,8 @@ int do_set_thread_area(struct task_struct *p, int idx,
 	modified_sel = (idx << 3) | 3;
 
 	if (p == current) {
+		unsigned short sel;
+
 #ifdef CONFIG_X86_64
 		savesegment(ds, sel);
 		if (sel == modified_sel)