Re: [PATCH] pidhash: Refactor the pid hash table.

From: Andrew Morton
Date: Fri Mar 10 2006 - 18:40:34 EST


ebiederm@xxxxxxxxxxxx (Eric W. Biederman) wrote:
>
> +fastcall void put_pid(struct pid *pid)
> +{
> + if (!pid)
> + return;
> + if ((atomic_read(&pid->count) == 1) ||
> + atomic_dec_and_test(&pid->count))
> + kmem_cache_free(pid_cachep, pid);
> +}

This looks odd. It's an RCU callback so it's asynchronous. It doesn't
take any locks, so if anyone else can have a ref on this thing then the
refcount can change at any time.

And both sides of the || are basically equivalent. Perhaps you meant &&.
But I'm more worried by the apparent raciness?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/