Kees Cook
4dd10fbbeb
treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family
...
Mirroring the earlier kmalloc_obj() conversion, convert the
device-managed allocators over to the type-based API using the now
updated scripts/coccinelle/api/kmalloc_objs.cocci. The size is derived
from the type rather than written out as a sizeof(), and the result is
a pointer to that type rather than void *, so a mismatch between the
size requested and the variable assigned becomes a build error instead
of being silently accepted.
The conversions break down as:
6713 devm_kzalloc_obj()
1749 devm_kzalloc_objs()
307 devm_kzalloc_flex()
91 devm_kmalloc_objs()
82 devm_kmalloc_obj()
2 devm_kmalloc_flex()
The rules deliberately leave alone allocations sized by a string or a
byte-sized type, or assigned to a pointer to a byte-sized type, since
those are byte buffers rather than objects. Allocations sized by a
multi-byte integer type are only converted when they are assigned to a
pointer to that same type, and allocations of pointers to integers or of
void pointers are left alone too. After this change, 528 files still
call devm_kmalloc(), devm_kzalloc(), devm_kcalloc(), or
devm_kmalloc_array().
Build tested with allmodconfig on x86_64, arm64, i386, arm, riscv, s390,
m68k, mips, parisc, sparc, loongarch, arc, xtensa, and openrisc with GCC
16.2.0 with no new warnings.
Signed-off-by: Kees Cook <[email protected] >
2026-11-05 21:55:50 -08:00
..
2026-04-30 12:53:04 +02:00
2026-06-03 18:27:05 +02:00
2026-10-22 07:48:17 -10:00
2026-10-15 14:25:07 +02:00
2026-02-21 20:03:00 -08:00
2026-03-11 09:59:29 +01:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-04-30 12:53:04 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-04-30 12:53:03 +02:00
2026-05-11 15:06:47 +02:00
2025-06-20 21:38:52 +02:00
2026-11-05 21:55:37 -08:00
2026-02-21 17:09:51 -08:00
2026-10-15 11:59:22 +02:00
2026-02-21 17:09:51 -08:00
2025-05-16 21:06:09 +02:00
2025-05-16 21:06:09 +02:00
2026-02-21 20:03:00 -08:00
2026-02-21 20:03:00 -08:00
2026-02-21 20:03:00 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-06-21 14:59:20 +02:00
2025-05-27 08:07:32 -07:00
2026-11-05 21:55:37 -08:00
2025-05-16 21:06:09 +02:00
2025-05-16 21:06:09 +02:00
2025-05-27 08:07:32 -07:00
2026-05-11 15:29:31 +02:00
2025-05-16 21:06:09 +02:00
2026-10-15 11:55:41 +02:00
2025-07-08 18:35:52 +01:00
2026-07-15 09:10:45 +02:00
2025-07-08 18:35:52 +01:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:37 -08:00
2026-02-21 17:09:51 -08:00
2026-10-15 12:02:17 +02:00
2025-06-20 13:52:29 -07:00
2026-10-23 13:37:12 -10:00
2026-11-05 21:55:37 -08:00
2026-10-15 14:25:06 +02:00
2026-10-23 13:37:12 -10:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2025-05-16 21:06:09 +02:00
2025-11-14 10:01:52 +01:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2025-05-16 21:06:07 +02:00
2026-10-15 11:59:22 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-06-03 22:28:11 +02:00
2026-07-09 15:30:18 +02:00
2026-09-04 21:37:00 -07:00
2026-10-15 12:16:59 +02:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-03-26 16:15:04 +01:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-06-03 22:28:11 +02:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2024-11-26 20:09:06 +01:00
2026-11-05 21:55:50 -08:00
2026-10-15 11:50:47 +02:00
2026-10-15 12:07:02 +02:00
2026-02-21 17:09:51 -08:00
2026-10-15 12:02:17 +02:00
2026-02-17 11:03:56 +01:00
2025-05-27 08:07:32 -07:00
2026-10-28 21:29:53 +01:00
2026-10-15 11:50:47 +02:00
2026-09-07 21:47:51 +02:00
2026-11-05 21:55:37 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-03-10 18:34:52 +01:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2025-05-16 21:06:09 +02:00
2025-09-03 14:10:30 +02:00
2025-05-16 21:06:09 +02:00
2026-01-16 16:38:56 +00:00
2026-01-16 16:38:56 +00:00
2025-05-16 21:06:09 +02:00
2026-02-21 17:09:51 -08:00
2026-04-07 11:19:02 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-09-04 21:37:00 -07:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-10-15 14:25:06 +02:00
2025-12-16 19:08:43 +01:00
2026-11-05 21:55:50 -08:00
2026-10-15 12:16:59 +02:00
2026-11-01 09:16:37 -08:00
2026-10-15 12:16:59 +02:00
2026-10-15 12:16:59 +02:00
2026-07-09 15:30:18 +02:00
2026-11-05 21:55:50 -08:00
2025-11-14 10:01:52 +01:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:37 -08:00
2026-11-05 21:55:50 -08:00
2026-10-15 14:25:06 +02:00
2025-05-16 21:06:09 +02:00
2026-11-05 21:55:50 -08:00
2026-05-06 09:13:12 +02:00
2026-02-22 08:26:33 -08:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2025-11-14 10:01:52 +01:00
2025-05-27 08:07:32 -07:00
2025-05-27 08:07:32 -07:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-06-10 10:38:21 +02:00
2026-02-21 17:09:51 -08:00
2026-09-07 21:47:51 +02:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:37 -08:00
2025-05-16 21:06:09 +02:00
2025-05-16 21:06:09 +02:00
2025-05-16 21:06:09 +02:00
2025-10-16 18:17:27 +02:00
2026-10-15 11:59:22 +02:00
2026-10-15 11:59:22 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2025-05-16 21:06:09 +02:00