Skip to content

Commit

Permalink
module: correctly exit module_kallsyms_on_each_symbol when fn() != 0
Browse files Browse the repository at this point in the history
[ Upstream commit 2c0f0f3 ]

Commit 013c166 ("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: 013c166 ("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>
  • Loading branch information
Jon Mediero authored and gregkh committed Jul 20, 2021
1 parent 74d6fce commit 9f6ffb1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/module.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9f6ffb1

Please sign in to comment.