X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=mm%2Fmempolicy.c;h=2da72a5b6ecc04f87bd9168fc31d613360e40f2e;hb=5c44ad6a35a9818039e301be289a1bb7ae77613e;hp=d8c4e38fb5f4be1d9748dc77f214c8a285374f8d;hpb=44cee85a8824464e7e951e590243c2a85d79c494;p=cascardo%2Flinux.git 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: return ret; } +/* + * Drop the (possibly final) reference to task->mempolicy. It needs to be + * dropped after task->mempolicy is set to NULL so that any allocation done as + * part of its kmem_cache_free(), such as by KASAN, doesn't reference a freed + * policy. + */ +void mpol_put_task_policy(struct task_struct *task) +{ + struct mempolicy *pol; + + task_lock(task); + pol = task->mempolicy; + task->mempolicy = NULL; + task_unlock(task); + mpol_put(pol); +} + static void sp_delete(struct shared_policy *sp, struct sp_node *n) { pr_debug("deleting %lx-l%lx\n", n->start, n->end);