Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 61549
b: refs/heads/master
c: 8cdd493
h: refs/heads/master
i:
  61547: e805cd1
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Linus Torvalds committed Jul 19, 2007
1 parent 212f0f1 commit ff40b6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b10d911749d37dccfa5873d2088aea3f074b9e45
refs/heads/master: 8cdd4936c17bd8085cb0dfacc4a37ccf8d0ada7b
31 changes: 30 additions & 1 deletion trunk/kernel/kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/resource.h>
#include <linux/notifier.h>
#include <linux/suspend.h>
#include <asm/uaccess.h>

extern int max_threads;

static struct workqueue_struct *khelper_wq;

/*
* If set, both call_usermodehelper_keys() and call_usermodehelper_pipe() exit
* immediately returning -EBUSY. Used for preventing user land processes from
* being created after the user land has been frozen during a system-wide
* hibernation or suspend operation.
*/
static int usermodehelper_disabled;

#ifdef CONFIG_KMOD

/*
Expand Down Expand Up @@ -265,6 +275,24 @@ static void __call_usermodehelper(struct work_struct *work)
}
}

static int usermodehelper_pm_callback(struct notifier_block *nfb,
unsigned long action,
void *ignored)
{
switch (action) {
case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE:
usermodehelper_disabled = 1;
return NOTIFY_OK;
case PM_POST_HIBERNATION:
case PM_POST_SUSPEND:
usermodehelper_disabled = 0;
return NOTIFY_OK;
}

return NOTIFY_DONE;
}

/**
* call_usermodehelper_setup - prepare to call a usermode helper
* @path - path to usermode executable
Expand Down Expand Up @@ -374,7 +402,7 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info,
goto out;
}

if (!khelper_wq) {
if (!khelper_wq || usermodehelper_disabled) {
retval = -EBUSY;
goto out;
}
Expand Down Expand Up @@ -431,4 +459,5 @@ void __init usermodehelper_init(void)
{
khelper_wq = create_singlethread_workqueue("khelper");
BUG_ON(!khelper_wq);
pm_notifier(usermodehelper_pm_callback, 0);
}

0 comments on commit ff40b6c

Please sign in to comment.