Re: [PATCH] [1/9] Add rcustring ADT for RCU protected strings v2

From: Bert Wesarg
Date: Mon Jan 11 2010 - 07:12:48 EST


On Tue, Jan 5, 2010 at 03:15, Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:
> Index: linux-2.6.33-rc2-ak/lib/rcustring.c
> ===================================================================
> --- /dev/null
> +++ linux-2.6.33-rc2-ak/lib/rcustring.c

[ . . . ]

> +/*
> + * Get a local private copy of a RCU protected string.
> + * Mostly useful to get a string that is stable while sleeping.
> + * Caller must free returned string.
> + */
> +char *access_rcu_string(char **str, int size, gfp_t gfp)
> +{
> + Â Â Â char *copy = kmalloc(size, gfp);
No check of return value from kmalloc()?

> + Â Â Â if (!str)
> + Â Â Â Â Â Â Â return NULL;
> + Â Â Â rcu_read_lock();
> + Â Â Â strlcpy(copy, rcu_dereference(*str), size);
> + Â Â Â rcu_read_unlock();
> + Â Â Â return copy;
> +}
> +EXPORT_SYMBOL(access_rcu_string);
--
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/