Date: Wed, 27 Apr 2022 15:16:19 GMT From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 4a5270b3c86c - stable/13 - linuxkpi: Add kstrtouint_from_user Message-ID: <202204271516.23RFGJtP008000@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=4a5270b3c86c50332b7cd829d82d110701d2ce81 commit 4a5270b3c86c50332b7cd829d82d110701d2ce81 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-03-22 09:22:42 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2022-04-27 16:34:47 +0000 linuxkpi: Add kstrtouint_from_user Like kstrtoint_from_user but for uint. Needed by drm v5.10 MFC after: 1 month Reviewed by: hselasky Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D34642 (cherry picked from commit 8e587a5f13ce676d7763ffa920148fe31bc3bfae) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 219a19e654d6..c22a711a4f47 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -525,6 +525,21 @@ kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, return (kstrtoint(buf, base, p)); } +static inline int +kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, + int *p) +{ + char buf[36] = {}; + + if (count > (sizeof(buf) - 1)) + count = (sizeof(buf) - 1); + + if (copy_from_user(buf, s, count)) + return (-EFAULT); + + return (kstrtouint(buf, base, p)); +} + static inline int kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *p)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204271516.23RFGJtP008000>