Skip to content

Commit

Permalink
Implement memdup_user_nul() in the LinuxKPI.
Browse files Browse the repository at this point in the history
MFC after:	1 week
Submitted by:	Johannes Lundberg <[email protected]>
Sponsored by:	Mellanox Technologies
  • Loading branch information
hselasky committed Feb 16, 2018
1 parent 0317e3d commit 2a76180
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sys/compat/linuxkpi/common/include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 2a76180

Please sign in to comment.