commit 543537bd922692bc978e2e356fcd8bfc9c2ee7d5 tree 0089e3907e7d6c17c01cffc6ea4a8962ed053079 parent 991114c6fa6a21d1fa4d544abe78592352860c82 author Paulo Marques Thu, 23 Jun 2005 00:09:02 -0700 committer Linus Torvalds Thu, 23 Jun 2005 09:45:18 -0700 [PATCH] create a kstrdup library function This patch creates a new kstrdup library function and changes the "local" implementations in several places to use this function. Most of the changes come from the sound and net subsystems. The sound part had already been acknowledged by Takashi Iwai and the net part by David S. Miller. I left UML alone for now because I would need more time to read the code carefully before making changes there. Signed-off-by: Paulo Marques Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds [Upstream] --- diff/drivers/md/dm-ioctl.c 2005-04-04 17:38:05.000000000 +0100 +++ source/drivers/md/dm-ioctl.c 2005-06-29 18:02:02.000000000 +0100 @@ -122,14 +122,6 @@ /*----------------------------------------------------------------- * Inserting, removing and renaming a device. *---------------------------------------------------------------*/ -static inline char *kstrdup(const char *str) -{ - char *r = kmalloc(strlen(str) + 1, GFP_KERNEL); - if (r) - strcpy(r, str); - return r; -} - static struct hash_cell *alloc_cell(const char *name, const char *uuid, struct mapped_device *md) { @@ -139,7 +131,7 @@ if (!hc) return NULL; - hc->name = kstrdup(name); + hc->name = kstrdup(name, GFP_KERNEL); if (!hc->name) { kfree(hc); return NULL; @@ -149,7 +141,7 @@ hc->uuid = NULL; else { - hc->uuid = kstrdup(uuid); + hc->uuid = kstrdup(uuid, GFP_KERNEL); if (!hc->uuid) { kfree(hc->name); kfree(hc); @@ -273,7 +265,7 @@ /* * duplicate new. */ - new_name = kstrdup(new); + new_name = kstrdup(new, GFP_KERNEL); if (!new_name) return -ENOMEM;