diff options
-rw-r--r-- | drivers/base/firmware_class.c | 5 | ||||
-rw-r--r-- | include/linux/kmod.h | 5 | ||||
-rw-r--r-- | kernel/kmod.c | 9 |
3 files changed, 19 insertions, 0 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 8c798ef7f13f..bbb03e6f7255 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -521,6 +521,11 @@ static int _request_firmware(const struct firmware **firmware_p, | |||
521 | if (!firmware_p) | 521 | if (!firmware_p) |
522 | return -EINVAL; | 522 | return -EINVAL; |
523 | 523 | ||
524 | if (WARN_ON(usermodehelper_is_disabled())) { | ||
525 | dev_err(device, "firmware: %s will not be loaded\n", name); | ||
526 | return -EBUSY; | ||
527 | } | ||
528 | |||
524 | *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); | 529 | *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); |
525 | if (!firmware) { | 530 | if (!firmware) { |
526 | dev_err(device, "%s: kmalloc(struct firmware) failed\n", | 531 | dev_err(device, "%s: kmalloc(struct firmware) failed\n", |
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 6efd7a78de6a..7f3dbcb78116 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -111,7 +111,12 @@ call_usermodehelper(char *path, char **argv, char **envp, enum umh_wait wait) | |||
111 | 111 | ||
112 | extern void usermodehelper_init(void); | 112 | extern void usermodehelper_init(void); |
113 | 113 | ||
114 | #ifdef CONFIG_PM_SLEEP | ||
114 | extern int usermodehelper_disable(void); | 115 | extern int usermodehelper_disable(void); |
115 | extern void usermodehelper_enable(void); | 116 | extern void usermodehelper_enable(void); |
117 | extern bool usermodehelper_is_disabled(void); | ||
118 | #else | ||
119 | static inline bool usermodehelper_is_disabled(void) { return false; } | ||
120 | #endif | ||
116 | 121 | ||
117 | #endif /* __LINUX_KMOD_H__ */ | 122 | #endif /* __LINUX_KMOD_H__ */ |
diff --git a/kernel/kmod.c b/kernel/kmod.c index 9cd0591c96a2..9ab513bd0c3c 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -301,6 +301,15 @@ void usermodehelper_enable(void) | |||
301 | usermodehelper_disabled = 0; | 301 | usermodehelper_disabled = 0; |
302 | } | 302 | } |
303 | 303 | ||
304 | /** | ||
305 | * usermodehelper_is_disabled - check if new helpers are allowed to be started | ||
306 | */ | ||
307 | bool usermodehelper_is_disabled(void) | ||
308 | { | ||
309 | return usermodehelper_disabled; | ||
310 | } | ||
311 | EXPORT_SYMBOL_GPL(usermodehelper_is_disabled); | ||
312 | |||
304 | static void helper_lock(void) | 313 | static void helper_lock(void) |
305 | { | 314 | { |
306 | atomic_inc(&running_helpers); | 315 | atomic_inc(&running_helpers); |