aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/slab.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 93cbbbb39f42..122d031baab2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -92,6 +92,7 @@
92#include <linux/sysctl.h> 92#include <linux/sysctl.h>
93#include <linux/module.h> 93#include <linux/module.h>
94#include <linux/rcupdate.h> 94#include <linux/rcupdate.h>
95#include <linux/string.h>
95 96
96#include <asm/uaccess.h> 97#include <asm/uaccess.h>
97#include <asm/cacheflush.h> 98#include <asm/cacheflush.h>
@@ -3082,3 +3083,26 @@ unsigned int ksize(const void *objp)
3082 3083
3083 return size; 3084 return size;
3084} 3085}
3086
3087
3088/*
3089 * kstrdup - allocate space for and copy an existing string
3090 *
3091 * @s: the string to duplicate
3092 * @gfp: the GFP mask used in the kmalloc() call when allocating memory
3093 */
3094char *kstrdup(const char *s, int gfp)
3095{
3096 size_t len;
3097 char *buf;
3098
3099 if (!s)
3100 return NULL;
3101
3102 len = strlen(s) + 1;
3103 buf = kmalloc(len, gfp);
3104 if (buf)
3105 memcpy(buf, s, len);
3106 return buf;
3107}
3108EXPORT_SYMBOL(kstrdup);