Re: [PATCH] [TRIVIAL] kstrdup

Valdis.Kletnieks@vt.edu
Mon, 13 Jan 2003 22:28:14 -0500


--==_Exmh_1500533200P
Content-Type: text/plain; charset=us-ascii

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()?

--==_Exmh_1500533200P
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Exmh version 2.5 07/13/2001

iD8DBQE+I4POcC3lWbTT17ARAi0QAJ4ubZHKMEBo8hrJG2nsIKRH16XAYwCfd/2V
iE95SeJnHdmPTYCxXBm436U=
=xTQD
-----END PGP SIGNATURE-----

--==_Exmh_1500533200P--
-
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/