Re: [PATCH] [1/2] random: SMP locking

From: Andrew Morton (akpm@osdl.org)
Date: Sat Aug 02 2003 - 14:46:47 EST


Matt Mackall <mpm@selenic.com> wrote:
>
> + spin_lock(&random_state->lock);
> + ent_count = random_state->entropy_count;
> + memcpy(tmp, random_state->pool, size * sizeof(__u32));
> + spin_unlock(&random_state->lock);
> +

This needs to be spin_lock_irqsave().

> + if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
> + kfree(tmp);
> + goto fail;
> + }
> +
> + kfree(tmp);
> +
> + if(put_user(ent_count, p++))
> + goto fail;
> +
> return 0;
> + fail:
> + spin_unlock(&random_state->lock);

Double unlock ;)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 07 2003 - 22:00:19 EST