[PATCH 2/6] vt: keyboard: publish npadch_value with release semantics
From: Jaidev Shastri via B4 Relay
Date: Mon Sep 21 2026 - 21:30:01 EST
From: Jaidev Shastri <jaidevshastri@xxxxxx>
k_ascii() accumulates the numeric keypad code in npadch_value after it
has set npadch_active. k_shift() tests npadch_active and then emits
npadch_value when the modifier is released.
Store the accumulated value with smp_store_release() and read it with
smp_load_acquire().
Found with MBCheck, a static herd7-based memory consistency checker.
Signed-off-by: Jaidev Shastri <jaidevshastri@xxxxxx>
---
drivers/tty/vt/keyboard.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 089f3b048..6f3472cd4 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -898,10 +898,13 @@ static void k_shift(struct vc_data *vc, unsigned char value, char up_flag)
/* kludge */
if (up_flag && shift_state != old_state && npadch_active) {
+ /* Pairs with the smp_store_release() in k_ascii(). */
+ unsigned int npadch = smp_load_acquire(&npadch_value);
+
if (kbd->kbdmode == VC_UNICODE)
- to_utf8(vc, npadch_value);
+ to_utf8(vc, npadch);
else
- put_queue(vc, npadch_value & 0xff);
+ put_queue(vc, npadch & 0xff);
npadch_active = false;
}
}
@@ -939,7 +942,8 @@ static void k_ascii(struct vc_data *vc, unsigned char value, char up_flag)
npadch_active = true;
}
- npadch_value = npadch_value * base + value;
+ /* Pairs with the smp_load_acquire() in k_shift(). */
+ smp_store_release(&npadch_value, npadch_value * base + value);
}
static void k_lock(struct vc_data *vc, unsigned char value, char up_flag)
--
2.43.0