Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kallsyms: clean up modname and modbuildid initialization in kallsyms_lookup_buildid()

The @modname and @modbuildid optional return parameters are set only when
the symbol is in a module.

Always initialize them so that they do not need to be cleared when the
module is not in a module. It simplifies the logic and makes the code
even slightly more safe.

Note that bpf_address_lookup() function will get updated in a separate
patch.

Link: https://lkml.kernel.org/r/20251128135920.217303-3-pmladek@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkman <daniel@iogearbox.net>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Luis Chamberalin <mcgrof@kernel.org>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Petr Mladek and committed by
Andrew Morton
fda024fb 426295ef

+8 -4
+8 -4
kernel/kallsyms.c
··· 362 362 * or empty string. 363 363 */ 364 364 namebuf[0] = 0; 365 + /* 366 + * Initialize the module-related return values. They are not set 367 + * when the symbol is in vmlinux or it is a bpf address. 368 + */ 369 + if (modname) 370 + *modname = NULL; 371 + if (modbuildid) 372 + *modbuildid = NULL; 365 373 366 374 if (is_ksym_addr(addr)) { 367 375 unsigned long pos; ··· 378 370 /* Grab name */ 379 371 kallsyms_expand_symbol(get_symbol_offset(pos), 380 372 namebuf, KSYM_NAME_LEN); 381 - if (modname) 382 - *modname = NULL; 383 - if (modbuildid) 384 - *modbuildid = NULL; 385 373 386 374 return strlen(namebuf); 387 375 }