LinuxKPI: add kvmemdup()

Add kvmemdup() as a variant of kmemdup().  While currently it could
just call kmemdup() we duplicate the code and use kvmalloc() in case
someone will change the implementation of kvmalloc/kvfree in slab.h.
This is used by an updated wireless driver.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D45181

(cherry picked from commit 8e4b8e9d80)
This commit is contained in:
Bjoern A. Zeeb 2024-05-13 17:43:25 +00:00
parent 787b336361
commit a87e584f6c

View file

@ -97,6 +97,18 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
}
/* See slab.h for kvmalloc/kvfree(). */
static inline void *
kvmemdup(const void *src, size_t len, gfp_t gfp)
{
void *dst;
dst = kvmalloc(len, gfp);
if (dst != NULL)
memcpy(dst, src, len);
return (dst);
}
static inline char *
strndup_user(const char __user *ustr, long n)
{