diff options
-rw-r--r-- | include/linux/string.h | 1 | ||||
-rw-r--r-- | mm/util.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/string.h b/include/linux/string.h index e4c755860316..4f69ef9e6eb5 100644 --- a/include/linux/string.h +++ b/include/linux/string.h | |||
@@ -99,6 +99,7 @@ extern void * memchr(const void *,int,__kernel_size_t); | |||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | extern char *kstrdup(const char *s, gfp_t gfp); | 101 | extern char *kstrdup(const char *s, gfp_t gfp); |
102 | extern void *kmemdup(const void *src, size_t len, gfp_t gfp); | ||
102 | 103 | ||
103 | #ifdef __cplusplus | 104 | #ifdef __cplusplus |
104 | } | 105 | } |
@@ -40,6 +40,24 @@ char *kstrdup(const char *s, gfp_t gfp) | |||
40 | } | 40 | } |
41 | EXPORT_SYMBOL(kstrdup); | 41 | EXPORT_SYMBOL(kstrdup); |
42 | 42 | ||
43 | /** | ||
44 | * kmemdup - duplicate region of memory | ||
45 | * | ||
46 | * @src: memory region to duplicate | ||
47 | * @len: memory region length | ||
48 | * @gfp: GFP mask to use | ||
49 | */ | ||
50 | void *kmemdup(const void *src, size_t len, gfp_t gfp) | ||
51 | { | ||
52 | void *p; | ||
53 | |||
54 | p = ____kmalloc(len, gfp); | ||
55 | if (p) | ||
56 | memcpy(p, src, len); | ||
57 | return p; | ||
58 | } | ||
59 | EXPORT_SYMBOL(kmemdup); | ||
60 | |||
43 | /* | 61 | /* |
44 | * strndup_user - duplicate an existing string from user space | 62 | * strndup_user - duplicate an existing string from user space |
45 | * | 63 | * |