git: 7643dd70a4df - main - linuxkpi: Add `kmemdup_array()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 22 Apr 2026 18:10:22 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=7643dd70a4dfa5fd874300a7161c24b808d6b134
commit 7643dd70a4dfa5fd874300a7161c24b808d6b134
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-04-12 22:23:06 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-22 18:09:54 +0000
linuxkpi: Add `kmemdup_array()`
It is similar to `kmemdup()` but takes a number of elements to duplicate
and their size.
The i915 DRM driver started to use it in Linux 6.12.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56444
---
sys/compat/linuxkpi/common/include/linux/string.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index 8ca20df27792..ad2b2fe7d377 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -98,6 +98,12 @@ kmemdup(const void *src, size_t len, gfp_t gfp)
return (dst);
}
+static inline void *
+kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
+{
+ return (kmemdup(src, size_mul(count, element_size), gfp));
+}
+
/* See slab.h for kvmalloc/kvfree(). */
static inline void *
kvmemdup(const void *src, size_t len, gfp_t gfp)