Commit c1a09f19 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by sanglipeng
Browse files

samples/hw_breakpoint: fix building without module unloading

stable inclusion
from stable-v5.10.197
commit 7be3a38f0e379ed3a68b293b3518e8ba5f700b32
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I96Q8P

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7be3a38f0e379ed3a68b293b3518e8ba5f700b32



--------------------------------

[ Upstream commit b9080468 ]

__symbol_put() is really meant as an internal helper and is not available
when module unloading is disabled, unlike the previously used symbol_put():

samples/hw_breakpoint/data_breakpoint.c: In function 'hw_break_module_exit':
samples/hw_breakpoint/data_breakpoint.c:73:9: error: implicit declaration of function '__symbol_put'; did you mean '__symbol_get'? [-Werror=implicit-function-declaration]

The hw_break_module_exit() function is not actually used when module
unloading is disabled, but it still causes the build failure for an
undefined identifier. Enclose this one call in an appropriate #ifdef to
clarify what the requirement is. Leaving out the entire exit function
would also work but feels less clar in this case.

Fixes: 910e230d ("samples/hw_breakpoint: Fix kernel BUG 'invalid opcode: 0000'")
Fixes: d8a84d33 ("samples/hw_breakpoint: drop use of kallsyms_lookup_name()")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 406fc9fa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -70,7 +70,9 @@ static int __init hw_break_module_init(void)
static void __exit hw_break_module_exit(void)
{
	unregister_wide_hw_breakpoint(sample_hbp);
#ifdef CONFIG_MODULE_UNLOAD
	__symbol_put(ksym_name);
#endif
	printk(KERN_INFO "HW Breakpoint for %s write uninstalled\n", ksym_name);
}