Re: [PATCH] [TRIVIAL] kstrdup

From: Valdis.Kletnieks@vt.edu
Date: Mon Jan 13 2003 - 22:28:14 EST


On Tue, 14 Jan 2003 12:55:40 +1100, Rusty Russell said:
> Everyone loves reimplementing strdup.

> +char *kstrdup(const char *s, int gfp)
> +{
> + char *buf = kmalloc(strlen(s)+1, gfp);
> + if (buf)
> + strcpy(buf, s);
> + return buf;
> +}

Out of curiosity, who's job is it to avoid the race condition between when
this function takes the strlen() and the other processor makes it a longer
string before we return from kmalloc() and do the strcpy()?



-
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 : Wed Jan 15 2003 - 22:00:48 EST