Re: [RFC] Fix failure path in alloc_pid()

From: Oleg Nesterov
Date: Thu Dec 20 2018 - 11:20:55 EST


On 12/18, Matthew Wilcox wrote:
>
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -233,8 +233,11 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>
> out_free:
> spin_lock_irq(&pidmap_lock);
> - while (++i <= ns->level)
> - idr_remove(&ns->idr, (pid->numbers + i)->nr);
> + upid = pid->numbers + i;
> + while (++i <= ns->level) {
> + upid++;
> + idr_remove(&upid->ns->idr, upid->nr);

can't resist...

while (++i <= ns->level) {
upid = pid->numbers + i;
idr_remove(&upid->ns->idr, upid->nr);
}

looks a bit more clean to me, but this is cosmetic and subjective.

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>