svn commit: r329954 - stable/11/sys/compat/linuxkpi/common/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Feb 25 10:18:50 UTC 2018
Author: hselasky
Date: Sun Feb 25 10:18:49 2018
New Revision: 329954
URL: https://svnweb.freebsd.org/changeset/base/329954
Log:
MFC r329377:
Implement memdup_user_nul() in the LinuxKPI.
Submitted by: Johannes Lundberg <johalun0 at gmail.com>
Sponsored by: Mellanox Technologies
Modified:
stable/11/sys/compat/linuxkpi/common/include/linux/string.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/compat/linuxkpi/common/include/linux/string.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/string.h Sun Feb 25 10:18:02 2018 (r329953)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/string.h Sun Feb 25 10:18:49 2018 (r329954)
@@ -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;
More information about the svn-src-all
mailing list