Page MenuHomeFreeBSD

linuxkpi: Add `kmemdup_array()`
ClosedPublic

Authored by dumbbell on Apr 16 2026, 9:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 18, 2:20 PM
Unknown Object (File)
Mon, May 18, 2:15 PM
Unknown Object (File)
Mon, May 18, 1:19 PM
Unknown Object (File)
Mon, May 18, 1:12 PM
Unknown Object (File)
Sun, May 17, 8:36 AM
Unknown Object (File)
Sun, May 17, 6:47 AM
Unknown Object (File)
Sat, May 16, 10:37 PM
Unknown Object (File)
Sat, May 16, 4:49 PM
Subscribers

Details

Summary

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.

This is part of the update of DRM drivers to Linux 6.12.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested changes to this revision.Apr 20 2026, 8:27 PM
bz added a subscriber: bz.
bz added inline comments.
sys/compat/linuxkpi/common/include/linux/string.h
108

I believe there is no need for a local variable but that's just noise.

I would add size_mul() to limit overflows like I did in f1834d03af617a93993056bb902082452673f89f .

{
       return (kmemdup(src, size_mul(count, element_size), gfp));
}
This revision now requires changes to proceed.Apr 20 2026, 8:27 PM
This revision is now accepted and ready to land.Wed, Apr 22, 1:39 PM
This revision was automatically updated to reflect the committed changes.