git: 8e4b8e9d807a - main - LinuxKPI: add kvmemdup()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 May 2024 22:15:26 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf commit 8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2024-05-13 17:43:25 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-05-21 22:14:50 +0000 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 MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45181 --- sys/compat/linuxkpi/common/include/linux/string.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 9e1818a38594..32470312b78b 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -98,6 +98,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) {