]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
module: correctly exit module_kallsyms_on_each_symbol when fn() != 0
authorJon Mediero <jmdr@disroot.org>
Thu, 20 May 2021 12:23:26 +0000 (14:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:02:17 +0000 (16:02 +0200)
[ Upstream commit 2c0f0f3639562d6e38ee9705303c6457c4936eac ]

Commit 013c1667cf78 ("kallsyms: refactor
{,module_}kallsyms_on_each_symbol") replaced the return inside the
nested loop with a break, changing the semantics of the function: the
break only exits the innermost loop, so the code continues iterating the
symbols of the next module instead of exiting.

Fixes: 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol")
Reviewed-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Jon Mediero <jmdr@disroot.org>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/module.c

index 260d6f3f6d68f6b8d40dd08f25a9864ba6a3a425..f928037a1b5676b1c54b8acf0f20fdef0d6fdeca 100644 (file)
@@ -4410,9 +4410,10 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
                        ret = fn(data, kallsyms_symbol_name(kallsyms, i),
                                 mod, kallsyms_symbol_value(sym));
                        if (ret != 0)
-                               break;
+                               goto out;
                }
        }
+out:
        mutex_unlock(&module_mutex);
        return ret;
 }