Skip to contentSkip to conversation

drivers/tty/vt/keyboard.c:1789:7: error: cannot jump from this asm goto statement to one of its possible targets

PATCH kernel test robot 2 participants 2 messages Sep 9, 2025 TTY layer and serial drivers

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git devel
head:   71311086e214f78774f7c36ef14866b211ea94df
commit: 215a9ed05f527245cba11f20f81cf39637088b78 [28/53] vt/keyboard: use __free()
config: arm64-randconfig-001-20250909 (https://download.01.org/0day-ci/archive/20250909/[email protected]/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250909/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/tty/vt/keyboard.c:1789:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1736:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
   drivers/tty/vt/keyboard.c:1722:23: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
                                       ^
   drivers/tty/vt/keyboard.c:1712:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:339:3: note: expanded from macro '__raw_put_user'
                   __raw_put_mem("sttr", __rpu_val, __rpu_ptr, __rpu_failed, U);   \
                   ^
   arch/arm64/include/asm/uaccess.h:309:3: note: expanded from macro '__raw_put_mem'
                   __put_mem_asm(str "b", "%w", __pu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm'
           asm goto(                                                       \
           ^
   drivers/tty/vt/keyboard.c:1736:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump exits scope of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
   drivers/tty/vt/keyboard.c:1722:23: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
                                       ^
   drivers/tty/vt/keyboard.c:1753:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
--
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:245:2: note: expanded from macro '__raw_get_user'
           __rgu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump exits scope of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
   drivers/tty/vt/keyboard.c:1753:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1789:7: note: possible target of asm goto statement
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:245:2: note: expanded from macro '__raw_get_user'
           __rgu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1747:33: note: jump exits scope of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = NULL;
                                                 ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
   drivers/tty/vt/keyboard.c:1736:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:339:3: note: expanded from macro '__raw_put_user'
                   __raw_put_mem("sttr", __rpu_val, __rpu_ptr, __rpu_failed, U);   \
                   ^
   arch/arm64/include/asm/uaccess.h:309:3: note: expanded from macro '__raw_put_mem'
                   __put_mem_asm(str "b", "%w", __pu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm'
           asm goto(                                                       \
           ^
   drivers/tty/vt/keyboard.c:1712:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1722:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
                                       ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
>> drivers/tty/vt/keyboard.c:1789:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1712:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
   drivers/tty/vt/keyboard.c:1753:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1712:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1747:33: note: jump exits scope of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = NULL;
                                                 ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
   drivers/tty/vt/keyboard.c:1736:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:339:3: note: expanded from macro '__raw_put_user'
                   __raw_put_mem("sttr", __rpu_val, __rpu_ptr, __rpu_failed, U);   \
                   ^
   arch/arm64/include/asm/uaccess.h:309:3: note: expanded from macro '__raw_put_mem'
                   __put_mem_asm(str "b", "%w", __pu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm'
           asm goto(                                                       \
           ^
   drivers/tty/vt/keyboard.c:1753:7: note: possible target of asm goto statement
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:245:2: note: expanded from macro '__raw_get_user'
           __rgu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1722:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
                                       ^
   drivers/tty/vt/keyboard.c:1747:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = NULL;
                                                 ^
>> drivers/tty/vt/keyboard.c:1789:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1753:7: note: possible target of asm goto statement
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:245:2: note: expanded from macro '__raw_get_user'
           __rgu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
   drivers/tty/vt/keyboard.c:1747:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = NULL;
                                                 ^
   drivers/tty/vt/keyboard.c:1712:7: error: cannot jump from this asm goto statement to one of its possible targets
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:339:3: note: expanded from macro '__raw_put_user'
                   __raw_put_mem("sttr", __rpu_val, __rpu_ptr, __rpu_failed, U);   \
                   ^
   arch/arm64/include/asm/uaccess.h:309:3: note: expanded from macro '__raw_put_mem'
                   __put_mem_asm(str "b", "%w", __pu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm'
           asm goto(                                                       \
           ^
   drivers/tty/vt/keyboard.c:1753:7: note: possible target of asm goto statement
                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:245:2: note: expanded from macro '__raw_get_user'
           __rgu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1692:33: note: jump exits scope of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                 ^
   drivers/tty/vt/keyboard.c:1747:33: note: jump bypasses initialization of variable with __attribute__((cleanup))
                   struct kbdiacr __free(kfree) *dia = NULL;
                                                 ^

12 errors generated.

vim +1789 drivers/tty/vt/keyboard.c

247ff8e610cb63 Alan Cox              2012-02-24  1671  
247ff8e610cb63 Alan Cox              2012-02-24  1672  /**
247ff8e610cb63 Alan Cox              2012-02-24  1673   *	vt_do_diacrit		-	diacritical table updates
247ff8e610cb63 Alan Cox              2012-02-24  1674   *	@cmd: ioctl request
9d329c1c68d2cc Mark Rustad           2014-09-05  1675   *	@udp: pointer to user data for ioctl
247ff8e610cb63 Alan Cox              2012-02-24  1676   *	@perm: permissions check computed by caller
247ff8e610cb63 Alan Cox              2012-02-24  1677   *
247ff8e610cb63 Alan Cox              2012-02-24  1678   *	Update the diacritical tables atomically and safely. Lock them
247ff8e610cb63 Alan Cox              2012-02-24  1679   *	against simultaneous keypresses
247ff8e610cb63 Alan Cox              2012-02-24  1680   */
9d329c1c68d2cc Mark Rustad           2014-09-05  1681  int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
247ff8e610cb63 Alan Cox              2012-02-24  1682  {
247ff8e610cb63 Alan Cox              2012-02-24  1683  	unsigned long flags;
247ff8e610cb63 Alan Cox              2012-02-24  1684  	int asize;
247ff8e610cb63 Alan Cox              2012-02-24  1685  
247ff8e610cb63 Alan Cox              2012-02-24  1686  	switch (cmd) {
247ff8e610cb63 Alan Cox              2012-02-24  1687  	case KDGKBDIACR:
247ff8e610cb63 Alan Cox              2012-02-24  1688  	{
9d329c1c68d2cc Mark Rustad           2014-09-05  1689  		struct kbdiacrs __user *a = udp;
247ff8e610cb63 Alan Cox              2012-02-24  1690  		int i;
247ff8e610cb63 Alan Cox              2012-02-24  1691  
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1692) 		struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
247ff8e610cb63 Alan Cox              2012-02-24  1693  								  GFP_KERNEL);
9d329c1c68d2cc Mark Rustad           2014-09-05  1694  		if (!dia)
247ff8e610cb63 Alan Cox              2012-02-24  1695  			return -ENOMEM;
247ff8e610cb63 Alan Cox              2012-02-24  1696  
247ff8e610cb63 Alan Cox              2012-02-24  1697  		/* Lock the diacriticals table, make a copy and then
247ff8e610cb63 Alan Cox              2012-02-24  1698  		   copy it after we unlock */
247ff8e610cb63 Alan Cox              2012-02-24  1699  		spin_lock_irqsave(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1700  
247ff8e610cb63 Alan Cox              2012-02-24  1701  		asize = accent_table_size;
247ff8e610cb63 Alan Cox              2012-02-24  1702  		for (i = 0; i < asize; i++) {
9d329c1c68d2cc Mark Rustad           2014-09-05  1703  			dia[i].diacr = conv_uni_to_8bit(
247ff8e610cb63 Alan Cox              2012-02-24  1704  						accent_table[i].diacr);
9d329c1c68d2cc Mark Rustad           2014-09-05  1705  			dia[i].base = conv_uni_to_8bit(
247ff8e610cb63 Alan Cox              2012-02-24  1706  						accent_table[i].base);
9d329c1c68d2cc Mark Rustad           2014-09-05  1707  			dia[i].result = conv_uni_to_8bit(
247ff8e610cb63 Alan Cox              2012-02-24  1708  						accent_table[i].result);
247ff8e610cb63 Alan Cox              2012-02-24  1709  		}
247ff8e610cb63 Alan Cox              2012-02-24  1710  		spin_unlock_irqrestore(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1711  
247ff8e610cb63 Alan Cox              2012-02-24  1712  		if (put_user(asize, &a->kb_cnt))
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1713) 			return -EFAULT;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1714) 		if (copy_to_user(a->kbdiacr, dia, asize * sizeof(struct kbdiacr)))
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1715) 			return -EFAULT;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1716) 		return 0;
247ff8e610cb63 Alan Cox              2012-02-24  1717  	}
247ff8e610cb63 Alan Cox              2012-02-24  1718  	case KDGKBDIACRUC:
247ff8e610cb63 Alan Cox              2012-02-24  1719  	{
9d329c1c68d2cc Mark Rustad           2014-09-05  1720  		struct kbdiacrsuc __user *a = udp;
247ff8e610cb63 Alan Cox              2012-02-24  1721  
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1722) 		void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
247ff8e610cb63 Alan Cox              2012-02-24  1723  							GFP_KERNEL);
247ff8e610cb63 Alan Cox              2012-02-24  1724  		if (buf == NULL)
247ff8e610cb63 Alan Cox              2012-02-24  1725  			return -ENOMEM;
247ff8e610cb63 Alan Cox              2012-02-24  1726  
247ff8e610cb63 Alan Cox              2012-02-24  1727  		/* Lock the diacriticals table, make a copy and then
247ff8e610cb63 Alan Cox              2012-02-24  1728  		   copy it after we unlock */
247ff8e610cb63 Alan Cox              2012-02-24  1729  		spin_lock_irqsave(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1730  
247ff8e610cb63 Alan Cox              2012-02-24  1731  		asize = accent_table_size;
247ff8e610cb63 Alan Cox              2012-02-24  1732  		memcpy(buf, accent_table, asize * sizeof(struct kbdiacruc));
247ff8e610cb63 Alan Cox              2012-02-24  1733  
247ff8e610cb63 Alan Cox              2012-02-24  1734  		spin_unlock_irqrestore(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1735  
247ff8e610cb63 Alan Cox              2012-02-24  1736  		if (put_user(asize, &a->kb_cnt))
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1737) 			return -EFAULT;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1738) 		if (copy_to_user(a->kbdiacruc, buf, asize * sizeof(struct kbdiacruc)))
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1739) 			return -EFAULT;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1740) 
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1741) 		return 0;
247ff8e610cb63 Alan Cox              2012-02-24  1742  	}
247ff8e610cb63 Alan Cox              2012-02-24  1743  
247ff8e610cb63 Alan Cox              2012-02-24  1744  	case KDSKBDIACR:
247ff8e610cb63 Alan Cox              2012-02-24  1745  	{
9d329c1c68d2cc Mark Rustad           2014-09-05  1746  		struct kbdiacrs __user *a = udp;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1747) 		struct kbdiacr __free(kfree) *dia = NULL;
247ff8e610cb63 Alan Cox              2012-02-24  1748  		unsigned int ct;
247ff8e610cb63 Alan Cox              2012-02-24  1749  		int i;
247ff8e610cb63 Alan Cox              2012-02-24  1750  
247ff8e610cb63 Alan Cox              2012-02-24  1751  		if (!perm)
247ff8e610cb63 Alan Cox              2012-02-24  1752  			return -EPERM;
247ff8e610cb63 Alan Cox              2012-02-24  1753  		if (get_user(ct, &a->kb_cnt))
247ff8e610cb63 Alan Cox              2012-02-24  1754  			return -EFAULT;
247ff8e610cb63 Alan Cox              2012-02-24  1755  		if (ct >= MAX_DIACR)
247ff8e610cb63 Alan Cox              2012-02-24  1756  			return -EINVAL;
247ff8e610cb63 Alan Cox              2012-02-24  1757  
247ff8e610cb63 Alan Cox              2012-02-24  1758  		if (ct) {
e651faa2fba4d3 Philipp Stanner       2023-11-03  1759  			dia = memdup_array_user(a->kbdiacr,
e651faa2fba4d3 Philipp Stanner       2023-11-03  1760  						ct, sizeof(struct kbdiacr));
1051937d465665 Saurabh Sengar        2015-10-28  1761  			if (IS_ERR(dia))
1051937d465665 Saurabh Sengar        2015-10-28  1762  				return PTR_ERR(dia);
247ff8e610cb63 Alan Cox              2012-02-24  1763  		}
247ff8e610cb63 Alan Cox              2012-02-24  1764  
247ff8e610cb63 Alan Cox              2012-02-24  1765  		spin_lock_irqsave(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1766  		accent_table_size = ct;
247ff8e610cb63 Alan Cox              2012-02-24  1767  		for (i = 0; i < ct; i++) {
247ff8e610cb63 Alan Cox              2012-02-24  1768  			accent_table[i].diacr =
9d329c1c68d2cc Mark Rustad           2014-09-05  1769  					conv_8bit_to_uni(dia[i].diacr);
247ff8e610cb63 Alan Cox              2012-02-24  1770  			accent_table[i].base =
9d329c1c68d2cc Mark Rustad           2014-09-05  1771  					conv_8bit_to_uni(dia[i].base);
247ff8e610cb63 Alan Cox              2012-02-24  1772  			accent_table[i].result =
9d329c1c68d2cc Mark Rustad           2014-09-05  1773  					conv_8bit_to_uni(dia[i].result);
247ff8e610cb63 Alan Cox              2012-02-24  1774  		}
247ff8e610cb63 Alan Cox              2012-02-24  1775  		spin_unlock_irqrestore(&kbd_event_lock, flags);
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1776) 
247ff8e610cb63 Alan Cox              2012-02-24  1777  		return 0;
247ff8e610cb63 Alan Cox              2012-02-24  1778  	}
247ff8e610cb63 Alan Cox              2012-02-24  1779  
247ff8e610cb63 Alan Cox              2012-02-24  1780  	case KDSKBDIACRUC:
247ff8e610cb63 Alan Cox              2012-02-24  1781  	{
9d329c1c68d2cc Mark Rustad           2014-09-05  1782  		struct kbdiacrsuc __user *a = udp;
247ff8e610cb63 Alan Cox              2012-02-24  1783  		unsigned int ct;
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1784) 		void __free(kfree) *buf = NULL;
247ff8e610cb63 Alan Cox              2012-02-24  1785  
247ff8e610cb63 Alan Cox              2012-02-24  1786  		if (!perm)
247ff8e610cb63 Alan Cox              2012-02-24  1787  			return -EPERM;
247ff8e610cb63 Alan Cox              2012-02-24  1788  
247ff8e610cb63 Alan Cox              2012-02-24 @1789  		if (get_user(ct, &a->kb_cnt))
247ff8e610cb63 Alan Cox              2012-02-24  1790  			return -EFAULT;
247ff8e610cb63 Alan Cox              2012-02-24  1791  
247ff8e610cb63 Alan Cox              2012-02-24  1792  		if (ct >= MAX_DIACR)
247ff8e610cb63 Alan Cox              2012-02-24  1793  			return -EINVAL;
247ff8e610cb63 Alan Cox              2012-02-24  1794  
247ff8e610cb63 Alan Cox              2012-02-24  1795  		if (ct) {
e651faa2fba4d3 Philipp Stanner       2023-11-03  1796  			buf = memdup_array_user(a->kbdiacruc,
e651faa2fba4d3 Philipp Stanner       2023-11-03  1797  						ct, sizeof(struct kbdiacruc));
9b6519009dbe2b Muhammad Falak R Wani 2016-05-20  1798  			if (IS_ERR(buf))
9b6519009dbe2b Muhammad Falak R Wani 2016-05-20  1799  				return PTR_ERR(buf);
247ff8e610cb63 Alan Cox              2012-02-24  1800  		} 
247ff8e610cb63 Alan Cox              2012-02-24  1801  		spin_lock_irqsave(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1802  		if (ct)
247ff8e610cb63 Alan Cox              2012-02-24  1803  			memcpy(accent_table, buf,
247ff8e610cb63 Alan Cox              2012-02-24  1804  					ct * sizeof(struct kbdiacruc));
247ff8e610cb63 Alan Cox              2012-02-24  1805  		accent_table_size = ct;
247ff8e610cb63 Alan Cox              2012-02-24  1806  		spin_unlock_irqrestore(&kbd_event_lock, flags);
247ff8e610cb63 Alan Cox              2012-02-24  1807  		return 0;
247ff8e610cb63 Alan Cox              2012-02-24  1808  	}
247ff8e610cb63 Alan Cox              2012-02-24  1809  	}
215a9ed05f5272 Jiri Slaby (SUSE      2025-08-19  1810) 	return 0;
247ff8e610cb63 Alan Cox              2012-02-24  1811  }
079c9534a96da9 Alan Cox              2012-02-28  1812  

:::::: The code at line 1789 was first introduced by commit :::::: 247ff8e610cb63c015de19191db9666754c2ed79 vt: lock the accent table

:::::: TO: Alan Cox <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 54 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git devel
head:   71311086e214f78774f7c36ef14866b211ea94df
commit: 215a9ed05f527245cba11f20f81cf39637088b78 [28/53] vt/keyboard: use __free()
config: arm64-randconfig-001-20250909 (https://download.01.org/0day-ci/archive/20250909/[email protected]/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250909/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/tty/vt/keyboard.c:1789:7: error: cannot jump from this asm goto statement to one of its possible targets

                   if (get_user(ct, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:272:18: note: expanded from macro 'get_user'
   #define get_user        __get_user
                           ^
   arch/arm64/include/asm/uaccess.h:268:2: note: expanded from macro '__get_user'
           __get_user_error((x), (ptr), __gu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:258:3: note: expanded from macro '__get_user_error'
                   __raw_get_user((x), __p, __gu_failed);                  \
                   ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   arch/arm64/include/asm/uaccess.h:211:3: note: expanded from macro '__raw_get_mem'
                   __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), label, type);     \
                   ^
   arch/arm64/include/asm/uaccess.h:189:2: note: expanded from macro '__get_mem_asm'
           asm_goto_output(                                                \
           ^
   include/linux/compiler_types.h:488:31: note: expanded from macro 'asm_goto_output'
   #define asm_goto_output(x...) asm volatile goto(x)
                                 ^
   drivers/tty/vt/keyboard.c:1736:7: note: possible target of asm goto statement
                   if (put_user(asize, &a->kb_cnt))
                       ^
   arch/arm64/include/asm/uaccess.h:369:18: note: expanded from macro 'put_user'
   #define put_user        __put_user
                           ^
   arch/arm64/include/asm/uaccess.h:365:2: note: expanded from macro '__put_user'
           __put_user_error((x), (ptr), __pu_err);                         \
           ^
   arch/arm64/include/asm/uaccess.h:355:3: note: expanded from macro '__put_user_error'
                   __raw_put_user((x), __p, __pu_failed);                  \
                   ^
   arch/arm64/include/asm/uaccess.h:342:2: note: expanded from macro '__raw_put_user'
           __rpu_failed:                                                   \
           ^
   drivers/tty/vt/keyboard.c:1784:23: note: jump exits scope of variable with __attribute__((cleanup))
                   void __free(kfree) *buf = NULL;
                                       ^
Quoted 3 lines

drivers/tty/vt/keyboard.c:1722:23: note: jump bypasses initialization of variable with __attribute__((cleanup))
void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
^

Unfortunately, this is an instance of
https://github.com/ClangBuiltLinux/linux/issues/1886#issuecomment-1645979992,
which was fixed in clang-17. This could be worked around by separating each case statement into its own function to hide from the scope checker but I am not sure how palpable that is...

Cheers,
Nathan

drivers/tty/vt/keyboard.c +115 -106
index 5c495753c883..1887bf34aa73 100644
@@ -1649,134 +1649,143 @@ int __init kbd_init(void)
 
 /* Ioctl support code */
 
-/**
- *	vt_do_diacrit		-	diacritical table updates
- *	@cmd: ioctl request
- *	@udp: pointer to user data for ioctl
- *	@perm: permissions check computed by caller
- *
- *	Update the diacritical tables atomically and safely. Lock them
- *	against simultaneous keypresses
- */
-int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
+static int vt_do_kdgkbdiacr(void __user *udp)
 {
-	int asize;
-
-	switch (cmd) {
-	case KDGKBDIACR:
-	{
-		struct kbdiacrs __user *a = udp;
-		int i;
+	struct kbdiacrs __user *a = udp;
+	int i, asize;
 
-		struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
-								  GFP_KERNEL);
-		if (!dia)
-			return -ENOMEM;
+	struct kbdiacr __free(kfree) *dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
+							  GFP_KERNEL);
+	if (!dia)
+		return -ENOMEM;
 
-		/* Lock the diacriticals table, make a copy and then
-		   copy it after we unlock */
-		scoped_guard(spinlock_irqsave, &kbd_event_lock) {
-			asize = accent_table_size;
-			for (i = 0; i < asize; i++) {
-				dia[i].diacr = conv_uni_to_8bit(accent_table[i].diacr);
-				dia[i].base = conv_uni_to_8bit(accent_table[i].base);
-				dia[i].result = conv_uni_to_8bit(accent_table[i].result);
-			}
+	/* Lock the diacriticals table, make a copy and then
+	   copy it after we unlock */
+	scoped_guard(spinlock_irqsave, &kbd_event_lock) {
+		asize = accent_table_size;
+		for (i = 0; i < asize; i++) {
+			dia[i].diacr = conv_uni_to_8bit(accent_table[i].diacr);
+			dia[i].base = conv_uni_to_8bit(accent_table[i].base);
+			dia[i].result = conv_uni_to_8bit(accent_table[i].result);
 		}
-
-		if (put_user(asize, &a->kb_cnt))
-			return -EFAULT;
-		if (copy_to_user(a->kbdiacr, dia, asize * sizeof(struct kbdiacr)))
-			return -EFAULT;
-		return 0;
 	}
-	case KDGKBDIACRUC:
-	{
-		struct kbdiacrsuc __user *a = udp;
 
-		void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
-							GFP_KERNEL);
-		if (buf == NULL)
-			return -ENOMEM;
+	if (put_user(asize, &a->kb_cnt))
+		return -EFAULT;
+	if (copy_to_user(a->kbdiacr, dia, asize * sizeof(struct kbdiacr)))
+		return -EFAULT;
+	return 0;
+}
 
-		/* Lock the diacriticals table, make a copy and then
-		   copy it after we unlock */
-		scoped_guard(spinlock_irqsave, &kbd_event_lock) {
-			asize = accent_table_size;
-			memcpy(buf, accent_table, asize * sizeof(struct kbdiacruc));
-		}
+static int vt_do_kdgkbdiacruc(void __user *udp)
+{
+	struct kbdiacrsuc __user *a = udp;
+	int asize;
 
-		if (put_user(asize, &a->kb_cnt))
-			return -EFAULT;
-		if (copy_to_user(a->kbdiacruc, buf, asize * sizeof(struct kbdiacruc)))
-			return -EFAULT;
+	void __free(kfree) *buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
+						GFP_KERNEL);
+	if (buf == NULL)
+		return -ENOMEM;
 
-		return 0;
+	/* Lock the diacriticals table, make a copy and then
+	   copy it after we unlock */
+	scoped_guard(spinlock_irqsave, &kbd_event_lock) {
+		asize = accent_table_size;
+		memcpy(buf, accent_table, asize * sizeof(struct kbdiacruc));
 	}
 
-	case KDSKBDIACR:
-	{
-		struct kbdiacrs __user *a = udp;
-		struct kbdiacr __free(kfree) *dia = NULL;
-		unsigned int ct;
-		int i;
+	if (put_user(asize, &a->kb_cnt))
+		return -EFAULT;
+	if (copy_to_user(a->kbdiacruc, buf, asize * sizeof(struct kbdiacruc)))
+		return -EFAULT;
 
-		if (!perm)
-			return -EPERM;
-		if (get_user(ct, &a->kb_cnt))
-			return -EFAULT;
-		if (ct >= MAX_DIACR)
-			return -EINVAL;
+	return 0;
+}
 
-		if (ct) {
-			dia = memdup_array_user(a->kbdiacr,
-						ct, sizeof(struct kbdiacr));
-			if (IS_ERR(dia))
-				return PTR_ERR(dia);
-		}
+static int vt_do_kdskbdiacr(void __user *udp, int perm)
+{
+	struct kbdiacrs __user *a = udp;
+	struct kbdiacr __free(kfree) *dia = NULL;
+	unsigned int ct;
+	int i;
 
-		guard(spinlock_irqsave)(&kbd_event_lock);
-		accent_table_size = ct;
-		for (i = 0; i < ct; i++) {
-			accent_table[i].diacr =
-					conv_8bit_to_uni(dia[i].diacr);
-			accent_table[i].base =
-					conv_8bit_to_uni(dia[i].base);
-			accent_table[i].result =
-					conv_8bit_to_uni(dia[i].result);
-		}
+	if (!perm)
+		return -EPERM;
+	if (get_user(ct, &a->kb_cnt))
+		return -EFAULT;
+	if (ct >= MAX_DIACR)
+		return -EINVAL;
 
-		return 0;
+	if (ct) {
+		dia = memdup_array_user(a->kbdiacr,
+					ct, sizeof(struct kbdiacr));
+		if (IS_ERR(dia))
+			return PTR_ERR(dia);
 	}
 
-	case KDSKBDIACRUC:
-	{
-		struct kbdiacrsuc __user *a = udp;
-		unsigned int ct;
-		void __free(kfree) *buf = NULL;
+	guard(spinlock_irqsave)(&kbd_event_lock);
+	accent_table_size = ct;
+	for (i = 0; i < ct; i++) {
+		accent_table[i].diacr =
+				conv_8bit_to_uni(dia[i].diacr);
+		accent_table[i].base =
+				conv_8bit_to_uni(dia[i].base);
+		accent_table[i].result =
+				conv_8bit_to_uni(dia[i].result);
+	}
 
-		if (!perm)
-			return -EPERM;
+	return 0;
+}
 
-		if (get_user(ct, &a->kb_cnt))
-			return -EFAULT;
+static int vt_do_kdskbdiacruc(void __user *udp, int perm)
+{
+	struct kbdiacrsuc __user *a = udp;
+	unsigned int ct;
+	void __free(kfree) *buf = NULL;
 
-		if (ct >= MAX_DIACR)
-			return -EINVAL;
+	if (!perm)
+		return -EPERM;
 
-		if (ct) {
-			buf = memdup_array_user(a->kbdiacruc,
-						ct, sizeof(struct kbdiacruc));
-			if (IS_ERR(buf))
-				return PTR_ERR(buf);
-		}
-		guard(spinlock_irqsave)(&kbd_event_lock);
-		if (ct)
-			memcpy(accent_table, buf,
-					ct * sizeof(struct kbdiacruc));
-		accent_table_size = ct;
-		return 0;
+	if (get_user(ct, &a->kb_cnt))
+		return -EFAULT;
+
+	if (ct >= MAX_DIACR)
+		return -EINVAL;
+
+	if (ct) {
+		buf = memdup_array_user(a->kbdiacruc,
+					ct, sizeof(struct kbdiacruc));
+		if (IS_ERR(buf))
+			return PTR_ERR(buf);
 	}
+	guard(spinlock_irqsave)(&kbd_event_lock);
+	if (ct)
+		memcpy(accent_table, buf,
+				ct * sizeof(struct kbdiacruc));
+	accent_table_size = ct;
+	return 0;
+}
+
+/**
+ *	vt_do_diacrit		-	diacritical table updates
+ *	@cmd: ioctl request
+ *	@udp: pointer to user data for ioctl
+ *	@perm: permissions check computed by caller
+ *
+ *	Update the diacritical tables atomically and safely. Lock them
+ *	against simultaneous keypresses
+ */
+int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
+{
+	switch (cmd) {
+	case KDGKBDIACR:
+		return vt_do_kdgkbdiacr(udp);
+	case KDGKBDIACRUC:
+		return vt_do_kdgkbdiacruc(udp);
+	case KDSKBDIACR:
+		return vt_do_kdskbdiacr(udp, perm);
+	case KDSKBDIACRUC:
+		return vt_do_kdskbdiacruc(udp, perm);
 	}
 	return 0;
 }