git: 8442bd342643 - stable/15 - linuxkpi: Add `kmemdup_array()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Apr 2026 21:42:59 UTC
The branch stable/15 has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=8442bd342643de2a2da725c9a35ddddb3317b10b
commit 8442bd342643de2a2da725c9a35ddddb3317b10b
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-29 21:03:48 +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
(cherry picked from commit 7643dd70a4dfa5fd874300a7161c24b808d6b134)
---
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)