Merge branch 'topic/misc' into for-linus
[firefly-linux-kernel-4.4.55.git] / mm / mempolicy.c
index 81a127643aea889675e9570ebee5653833e55e95..11ff260fb282b778657a872aec0947d5f15616c6 100644 (file)
@@ -1307,15 +1307,18 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
                goto out;
 
        /* Find the mm_struct */
+       rcu_read_lock();
        read_lock(&tasklist_lock);
        task = pid ? find_task_by_vpid(pid) : current;
        if (!task) {
                read_unlock(&tasklist_lock);
+               rcu_read_unlock();
                err = -ESRCH;
                goto out;
        }
        mm = get_task_mm(task);
        read_unlock(&tasklist_lock);
+       rcu_read_unlock();
 
        err = -EINVAL;
        if (!mm)
@@ -1597,7 +1600,7 @@ unsigned slab_node(struct mempolicy *policy)
                (void)first_zones_zonelist(zonelist, highest_zoneidx,
                                                        &policy->v.nodes,
                                                        &zone);
-               return zone->node;
+               return zone ? zone->node : numa_node_id();
        }
 
        default: