[Devel] [PATCH RH9 06/30] include/linux/sockptr: introduce vmemdup_sockptr helper
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Sep 28 21:48:57 MSK 2021
This helper is needed for next patch
https://jira.sw.ru/browse/PSBM-133996
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
include/linux/sockptr.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h
index ea19341..3538721 100644
--- a/include/linux/sockptr.h
+++ b/include/linux/sockptr.h
@@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
+#include <linux/mm.h>
typedef struct {
union {
@@ -77,6 +78,19 @@ static inline void *memdup_sockptr(sockptr_t src, size_t len)
return p;
}
+static inline void *vmemdup_sockptr(sockptr_t src, size_t len)
+{
+ void *p = kvmalloc(len, GFP_USER);
+
+ if (!p)
+ return ERR_PTR(-ENOMEM);
+ if (copy_from_sockptr(p, src, len)) {
+ kvfree(p);
+ return ERR_PTR(-EFAULT);
+ }
+ return p;
+}
+
static inline void *memdup_sockptr_nul(sockptr_t src, size_t len)
{
char *p = kmalloc_track_caller(len + 1, GFP_KERNEL);
--
1.8.3.1
More information about the Devel
mailing list