Implement memdup_user_nul() in the LinuxKPI.
MFC after: 1 week Submitted by: Johannes Lundberg <johalun0@gmail.com> Sponsored by: Mellanox Technologies
This commit is contained in:
parent
f1f7e04a29
commit
10ee3d3016
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329377
@ -70,6 +70,22 @@ memdup_user(const void *ptr, size_t len)
|
||||
return (retval);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user