diff options
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index cd36a5e0d173..4fd07d5b7baf 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -182,7 +182,7 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) | |||
182 | spin_unlock_irq(&pidmap_lock); | 182 | spin_unlock_irq(&pidmap_lock); |
183 | kfree(page); | 183 | kfree(page); |
184 | if (unlikely(!map->page)) | 184 | if (unlikely(!map->page)) |
185 | break; | 185 | return -ENOMEM; |
186 | } | 186 | } |
187 | if (likely(atomic_read(&map->nr_free))) { | 187 | if (likely(atomic_read(&map->nr_free))) { |
188 | for ( ; ; ) { | 188 | for ( ; ; ) { |
@@ -210,7 +210,7 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) | |||
210 | } | 210 | } |
211 | pid = mk_pid(pid_ns, map, offset); | 211 | pid = mk_pid(pid_ns, map, offset); |
212 | } | 212 | } |
213 | return -1; | 213 | return -EAGAIN; |
214 | } | 214 | } |
215 | 215 | ||
216 | int next_pidmap(struct pid_namespace *pid_ns, unsigned int last) | 216 | int next_pidmap(struct pid_namespace *pid_ns, unsigned int last) |
@@ -301,17 +301,20 @@ struct pid *alloc_pid(struct pid_namespace *ns) | |||
301 | int i, nr; | 301 | int i, nr; |
302 | struct pid_namespace *tmp; | 302 | struct pid_namespace *tmp; |
303 | struct upid *upid; | 303 | struct upid *upid; |
304 | int retval = -ENOMEM; | ||
304 | 305 | ||
305 | pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); | 306 | pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); |
306 | if (!pid) | 307 | if (!pid) |
307 | goto out; | 308 | return ERR_PTR(retval); |
308 | 309 | ||
309 | tmp = ns; | 310 | tmp = ns; |
310 | pid->level = ns->level; | 311 | pid->level = ns->level; |
311 | for (i = ns->level; i >= 0; i--) { | 312 | for (i = ns->level; i >= 0; i--) { |
312 | nr = alloc_pidmap(tmp); | 313 | nr = alloc_pidmap(tmp); |
313 | if (nr < 0) | 314 | if (IS_ERR_VALUE(nr)) { |
315 | retval = nr; | ||
314 | goto out_free; | 316 | goto out_free; |
317 | } | ||
315 | 318 | ||
316 | pid->numbers[i].nr = nr; | 319 | pid->numbers[i].nr = nr; |
317 | pid->numbers[i].ns = tmp; | 320 | pid->numbers[i].ns = tmp; |
@@ -339,7 +342,6 @@ struct pid *alloc_pid(struct pid_namespace *ns) | |||
339 | } | 342 | } |
340 | spin_unlock_irq(&pidmap_lock); | 343 | spin_unlock_irq(&pidmap_lock); |
341 | 344 | ||
342 | out: | ||
343 | return pid; | 345 | return pid; |
344 | 346 | ||
345 | out_unlock: | 347 | out_unlock: |
@@ -351,8 +353,7 @@ out_free: | |||
351 | free_pidmap(pid->numbers + i); | 353 | free_pidmap(pid->numbers + i); |
352 | 354 | ||
353 | kmem_cache_free(ns->pid_cachep, pid); | 355 | kmem_cache_free(ns->pid_cachep, pid); |
354 | pid = NULL; | 356 | return ERR_PTR(retval); |
355 | goto out; | ||
356 | } | 357 | } |
357 | 358 | ||
358 | void disable_pid_allocation(struct pid_namespace *ns) | 359 | void disable_pid_allocation(struct pid_namespace *ns) |