Skip to content

Commit ac3061b

Browse files
pmladekKernel Patches Daemon
authored andcommitted
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. Signed-off-by: Petr Mladek <[email protected]>
1 parent b5afc94 commit ac3061b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kernel/kallsyms.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ static int kallsyms_lookup_buildid(unsigned long addr,
359359
* or empty string.
360360
*/
361361
namebuf[0] = 0;
362+
/*
363+
* Initialize the module-related return values. They are not set
364+
* when the symbol is in vmlinux or it is a bpf address.
365+
*/
366+
if (modname)
367+
*modname = NULL;
368+
if (modbuildid)
369+
*modbuildid = NULL;
362370

363371
if (is_ksym_addr(addr)) {
364372
unsigned long pos;
@@ -367,10 +375,6 @@ static int kallsyms_lookup_buildid(unsigned long addr,
367375
/* Grab name */
368376
kallsyms_expand_symbol(get_symbol_offset(pos),
369377
namebuf, KSYM_NAME_LEN);
370-
if (modname)
371-
*modname = NULL;
372-
if (modbuildid)
373-
*modbuildid = NULL;
374378

375379
return strlen(namebuf);
376380
}

0 commit comments

Comments
 (0)