FATAL: modpost: GPL-incompatible module *.ko uses GPL-only symbol ‘mutex_destroy’

Problem of day: trying to debug a linux kernel lock.

I rebuilt the Linux kernel with debugging enabled:

CONFIG_UNINLINE_SPIN_UNLOCK=y
CONFIG_DEBUG_SPINLOCK=y
CONFIG_DEBUG_MUTEXES=y
CONFIG_DEBUG_LOCK_ALLOC=y
CONFIG_PROVE_LOCKING=y
CONFIG_LOCKDEP=y
# CONFIG_DEBUG_LOCKDEP is not set
CONFIG_TRACE_IRQFLAGS=y
CONFIG_PROVE_RCU=y
# CONFIG_PROVE_RCU_REPEATEDLY is not setCode language: PHP (php)

The device I’m developing for has an out of tree proprietary kernel module for a hardware card. With the kernel debug flags enabled it will not build:

FATAL: modpost: GPL-incompatible module *.ko uses GPL-only symbol ‘mutex_destroy’Code language: JavaScript (javascript)

The quick and dirty temporary fix I found to continue debugging is to patch the kernel to suppress the error while debugging, and revert the changes when a solution will be found

diff --git a/include/linux/export.h b/include/linux/export.h
index 2a0f61fbc731..6cde38c3b770 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -97,14 +97,14 @@ extern struct module __this_module;
        __EXPORT_SYMBOL(sym, "")
 
 #define EXPORT_SYMBOL_GPL(sym)                                 \
-       __EXPORT_SYMBOL(sym, "_gpl")
+       __EXPORT_SYMBOL(sym, "")
 
 #define EXPORT_SYMBOL_GPL_FUTURE(sym)                          \
-       __EXPORT_SYMBOL(sym, "_gpl_future")
+       __EXPORT_SYMBOL(sym, "")
 
 #ifdef CONFIG_UNUSED_SYMBOLS
 #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
-#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
+#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused")
 #else
 #define EXPORT_UNUSED_SYMBOL(sym)
 #define EXPORT_UNUSED_SYMBOL_GPL(sym)Code language: Diff (diff)

Leave a Reply

Your email address will not be published. Required fields are marked *