diff options
author | hselasky <hselasky@FreeBSD.org> | 2018-02-25 10:18:49 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2018-02-25 10:18:49 +0000 |
commit | 181e24e09d8534a506b3ec5c243ede6cebab03ef (patch) | |
tree | 6fa5e9af30ee91051af1ce9e5e769ab784122662 | |
parent | 3aba0a58657077eb5f2be3deee1dfd7d718bf914 (diff) | |
download | FreeBSD-src-181e24e09d8534a506b3ec5c243ede6cebab03ef.zip FreeBSD-src-181e24e09d8534a506b3ec5c243ede6cebab03ef.tar.gz |
MFC r329377:
Implement memdup_user_nul() in the LinuxKPI.
Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/string.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index a47eb42..918ff81 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -71,6 +71,22 @@ memdup_user(const void *ptr, size_t len) } static inline void * +memdup_user_nul(const void *ptr, size_t len) +{ + char *retval; + int error; + + retval = malloc(len + 1, M_KMALLOC, M_WAITOK); + error = linux_copyin(ptr, retval, len); + if (error != 0) { + free(retval, M_KMALLOC); + return (ERR_PTR(error)); + } + retval[len] = '\0'; + return (retval); +} + +static inline void * kmemdup(const void *src, size_t len, gfp_t gfp) { void *dst; |