git: 395833f4ea8f - stable/13 - LinuxKPI: add kvmemdup()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 12 Jun 2024 19:16:48 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=395833f4ea8f4852f47ca1473baf99239331379e commit 395833f4ea8f4852f47ca1473baf99239331379e Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2024-05-13 17:43:25 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2024-06-12 16:57:56 +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 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D45181 (cherry picked from commit 8e4b8e9d807aa379d2a1c3aaac2537ba7d6bf0bf) --- 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 06dcdbd97663..9302c95e8636 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -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) {