linuxkpi: Add strndup_user

Reviewed by:	hselasky, markj
Differential Revision:	https://reviews.freebsd.org/D36350
Sponsored by:	Google, Inc. (GSoC 2022)
This commit is contained in:
Jake Freeland 2022-09-20 19:38:37 +02:00 committed by Emmanuel Vadot
parent a06eeeaa1d
commit a11195df34

View File

@ -98,6 +98,15 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
}
static inline char *
strndup_user(const char __user *ustr, long n)
{
if (n < 1)
return (ERR_PTR(-EINVAL));
return (memdup_user_nul(ustr, n - 1));
}
static inline char *
kstrdup(const char *string, gfp_t gfp)
{