summaryrefslogtreecommitdiffstats
path: root/kernel/module/internal.h
diff options
context:
space:
mode:
authorAaron Tomlin <atomlin@redhat.com>2022-05-02 22:51:04 +0200
committerLuis Chamberlain <mcgrof@kernel.org>2022-05-12 19:29:41 +0200
commit6fb0538d0121ffab770a505b183968d93466ad59 (patch)
treee4d104d7f43375d7a2142d162644d2a68e12cd9d /kernel/module/internal.h
parentmodule: Make module_flags_taint() accept a module's taints bitmap and usable ... (diff)
downloadlinux-6fb0538d0121ffab770a505b183968d93466ad59.tar.xz
linux-6fb0538d0121ffab770a505b183968d93466ad59.zip
module: Move module_assert_mutex_or_preempt() to internal.h
No functional change. This patch migrates module_assert_mutex_or_preempt() to internal.h. So, the aforementiond function can be used outside of main/or core module code yet will remain restricted for internal use only. Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Diffstat (limited to 'kernel/module/internal.h')
-rw-r--r--kernel/module/internal.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/module/internal.h b/kernel/module/internal.h
index abbd1c5ef264..0bdf64c9dfb5 100644
--- a/kernel/module/internal.h
+++ b/kernel/module/internal.h
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/rculist.h>
+#include <linux/rcupdate.h>
#ifndef ARCH_SHF_SMALL
#define ARCH_SHF_SMALL 0
@@ -102,6 +103,17 @@ long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
char *module_flags(struct module *mod, char *buf);
size_t module_flags_taint(unsigned long taints, char *buf);
+static inline void module_assert_mutex_or_preempt(void)
+{
+#ifdef CONFIG_LOCKDEP
+ if (unlikely(!debug_locks))
+ return;
+
+ WARN_ON_ONCE(!rcu_read_lock_sched_held() &&
+ !lockdep_is_held(&module_mutex));
+#endif
+}
+
static inline unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
{
#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS