summaryrefslogtreecommitdiff
path: root/lib/linux_compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/linux_compat.c')
-rw-r--r--lib/linux_compat.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/linux_compat.c b/lib/linux_compat.c
index 81ea8fb126..3f440deaa0 100644
--- a/lib/linux_compat.c
+++ b/lib/linux_compat.c
@@ -40,3 +40,22 @@ void *kmem_cache_alloc(struct kmem_cache *obj, int flag)
{
return malloc_cache_aligned(obj->sz);
}
+
+/**
+ * kmemdup - duplicate region of memory
+ *
+ * @src: memory region to duplicate
+ * @len: memory region length
+ * @gfp: GFP mask to use
+ *
+ * Return: newly allocated copy of @src or %NULL in case of error
+ */
+void *kmemdup(const void *src, size_t len, gfp_t gfp)
+{
+ void *p;
+
+ p = kmalloc(len, gfp);
+ if (p)
+ memcpy(p, src, len);
+ return p;
+}