diff options
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r-- | mm/mempolicy.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d8c4e38fb5f4..2da72a5b6ecc 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -2336,6 +2336,23 @@ out: | |||
2336 | return ret; | 2336 | return ret; |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | /* | ||
2340 | * Drop the (possibly final) reference to task->mempolicy. It needs to be | ||
2341 | * dropped after task->mempolicy is set to NULL so that any allocation done as | ||
2342 | * part of its kmem_cache_free(), such as by KASAN, doesn't reference a freed | ||
2343 | * policy. | ||
2344 | */ | ||
2345 | void mpol_put_task_policy(struct task_struct *task) | ||
2346 | { | ||
2347 | struct mempolicy *pol; | ||
2348 | |||
2349 | task_lock(task); | ||
2350 | pol = task->mempolicy; | ||
2351 | task->mempolicy = NULL; | ||
2352 | task_unlock(task); | ||
2353 | mpol_put(pol); | ||
2354 | } | ||
2355 | |||
2339 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) | 2356 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) |
2340 | { | 2357 | { |
2341 | pr_debug("deleting %lx-l%lx\n", n->start, n->end); | 2358 | pr_debug("deleting %lx-l%lx\n", n->start, n->end); |