atm: idt77252: fix a memleak in open_card_ubr0
[platform/kernel/linux-rpi.git] / kernel / kallsyms.c
index 016d997..18edd57 100644 (file)
@@ -163,12 +163,12 @@ unsigned long kallsyms_sym_address(int idx)
        return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
 }
 
-static bool cleanup_symbol_name(char *s)
+static void cleanup_symbol_name(char *s)
 {
        char *res;
 
        if (!IS_ENABLED(CONFIG_LTO_CLANG))
-               return false;
+               return;
 
        /*
         * LLVM appends various suffixes for local functions and variables that
@@ -178,26 +178,21 @@ static bool cleanup_symbol_name(char *s)
         * - foo.llvm.[0-9a-f]+
         */
        res = strstr(s, ".llvm.");
-       if (res) {
+       if (res)
                *res = '\0';
-               return true;
-       }
 
-       return false;
+       return;
 }
 
 static int compare_symbol_name(const char *name, char *namebuf)
 {
-       int ret;
-
-       ret = strcmp(name, namebuf);
-       if (!ret)
-               return ret;
-
-       if (cleanup_symbol_name(namebuf) && !strcmp(name, namebuf))
-               return 0;
-
-       return ret;
+       /* The kallsyms_seqs_of_names is sorted based on names after
+        * cleanup_symbol_name() (see scripts/kallsyms.c) if clang lto is enabled.
+        * To ensure correct bisection in kallsyms_lookup_names(), do
+        * cleanup_symbol_name(namebuf) before comparing name and namebuf.
+        */
+       cleanup_symbol_name(namebuf);
+       return strcmp(name, namebuf);
 }
 
 static unsigned int get_symbol_seq(int index)