From: Jon Mediero Date: Thu, 20 May 2021 12:23:26 +0000 (+0200) Subject: module: correctly exit module_kallsyms_on_each_symbol when fn() != 0 X-Git-Tag: v5.12.19~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f6ffb15d64d2e59f7be6de3c6071e806ef9ea14;p=thirdparty%2Fkernel%2Fstable.git module: correctly exit module_kallsyms_on_each_symbol when fn() != 0 [ 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 Reviewed-by: Miroslav Benes Signed-off-by: Jon Mediero Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- diff --git a/kernel/module.c b/kernel/module.c index 260d6f3f6d68f..f928037a1b567 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -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; }