aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kmod.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 8ea25944ce33..f92f917c450c 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -201,7 +201,15 @@ EXPORT_SYMBOL(call_usermodehelper_freeinfo);
201 201
202static void umh_complete(struct subprocess_info *sub_info) 202static void umh_complete(struct subprocess_info *sub_info)
203{ 203{
204 complete(sub_info->complete); 204 struct completion *comp = xchg(&sub_info->complete, NULL);
205 /*
206 * See call_usermodehelper_exec(). If xchg() returns NULL
207 * we own sub_info, the UMH_KILLABLE caller has gone away.
208 */
209 if (comp)
210 complete(comp);
211 else
212 call_usermodehelper_freeinfo(sub_info);
205} 213}
206 214
207/* Keventd can't block, but this (a child) can. */ 215/* Keventd can't block, but this (a child) can. */
@@ -252,6 +260,9 @@ static void __call_usermodehelper(struct work_struct *work)
252 enum umh_wait wait = sub_info->wait; 260 enum umh_wait wait = sub_info->wait;
253 pid_t pid; 261 pid_t pid;
254 262
263 if (wait != UMH_NO_WAIT)
264 wait &= ~UMH_KILLABLE;
265
255 /* CLONE_VFORK: wait until the usermode helper has execve'd 266 /* CLONE_VFORK: wait until the usermode helper has execve'd
256 * successfully We need the data structures to stay around 267 * successfully We need the data structures to stay around
257 * until that is done. */ 268 * until that is done. */
@@ -461,9 +472,21 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info,
461 queue_work(khelper_wq, &sub_info->work); 472 queue_work(khelper_wq, &sub_info->work);
462 if (wait == UMH_NO_WAIT) /* task has freed sub_info */ 473 if (wait == UMH_NO_WAIT) /* task has freed sub_info */
463 goto unlock; 474 goto unlock;
475
476 if (wait & UMH_KILLABLE) {
477 retval = wait_for_completion_killable(&done);
478 if (!retval)
479 goto wait_done;
480
481 /* umh_complete() will see NULL and free sub_info */
482 if (xchg(&sub_info->complete, NULL))
483 goto unlock;
484 /* fallthrough, umh_complete() was already called */
485 }
486
464 wait_for_completion(&done); 487 wait_for_completion(&done);
488wait_done:
465 retval = sub_info->retval; 489 retval = sub_info->retval;
466
467out: 490out:
468 call_usermodehelper_freeinfo(sub_info); 491 call_usermodehelper_freeinfo(sub_info);
469unlock: 492unlock: