On 07/29, Adrian Reber wrote:
>
> @@ -186,12 +187,26 @@ struct pid *alloc_pid(struct pid_namespace *ns)
>               if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS)
>                       pid_min = RESERVED_PIDS;
>  
> +             if (set_tid) {
> +                     if ((set_tid >= pid_max) || ((set_tid != 1) &&
> +                             (idr_get_cursor(&tmp->idr) <= 1))) {

I think the

        (set_tid != 1) && idr_get_cursor() <= 1

check needs a comment...

> +                             spin_unlock_irq(&pidmap_lock);
> +                             retval = -EINVAL;
> +                             goto out_free;
> +                     }
> +                     min_p = set_tid;
> +                     max_p = set_tid + 1;
> +                     set_tid = 0;
> +             } else {
> +                     min_p = pid_min;
> +                     max_p = pid_max;
> +             }
>               /*
>                * Store a null pointer so find_pid_ns does not find
>                * a partially initialized PID (see below).
>                */
> -             nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min,
> -                                   pid_max, GFP_ATOMIC);
> +             nr = idr_alloc_cyclic(&tmp->idr, NULL, min_p,
> +                                   max_p, GFP_ATOMIC);

do we really want _cyclic() which updates idr->idr_next if set_tid?

perhaps idr_alloc() makes more sense?

Oleg.

Reply via email to