Messages in this thread | | | Subject | Re: [PATCH] [TRIVIAL] kstrdup | From | Valdis.Kletnieks@vt ... | Date | Mon, 13 Jan 2003 22:28:14 -0500 |
| |
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()?
[unhandled content-type:application/pgp-signature] | |