Re: [PATCH 4/4] libkeymap: add NULL check in lk_dump_ctable diacritical loop

Alexey Gladkov <[email protected]> Sun, 15 Feb 2026 18:49:06 +0100
Newsgroups dev.linux.lists.kbd
Message-ID <[email protected]>
On Sun, Feb 15, 2026 at 11:04:05AM +0300, Areg Krdyan wrote:
> Thanks for the reply! All the changes that I made were done by myself.
> 
> I am currently undergoing an internship at Redsoft and my task is to
> check the output of the static analyzer for kbd. I also wanted to fix
> these static analyzer calls, some of them have already been fixed. Not
> all of them are real errors, but they can help to detect the error
> when changing the code.

That's good, but the desire to satisfy the static analyzer should not be
the only reason for making changes. Especially if the analyzer clearly
does not fully understand the code.

> Such checks are already in the project. Eg:
> for (t = 0; t < MAX_NR_KEYMAPS; t++) { // libkeymap/kernel.c:24
>     if (t > UCHAR_MAX) {
>         ERR(ctx, _("table %d must be less than %d"), t, UCHAR_MAX);
>         return -1;
>     }
>     .....
> }
> With these constants, the error will never be triggered, since
> MAX_NR_KEYMAPS = 256 and UCHAR_MAX = 255. But in the future, when
> changing MAX_NR_KEYMAPS, it will be useful to have a check to detect
> an error.

The check for UCHAR_MAX here is not because of MAX_NR_KEYMAPS, but because
KDGKBENT/KDSKBENT use struct kbentry, which defines kb_table as unsigned
char. This cannot be changed because it is part of the Linux kernel API.

> 
> Please let me know if patches of this kind are not needed.
> Thanks again for your time.
> 

-- 
Rgrds, legion