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-11-05 21:55:50 -08:00
2026-10-21 21:29:27 +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-11-05 21:55:50 -08:00
2026-10-21 21:44:43 +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-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
2024-08-27 16:29:55 +02:00
2026-08-14 14:46:20 +02:00
2026-06-01 18:28:41 +02:00
2026-08-14 14:46:20 +02:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2024-08-27 16:29:55 +02:00
2026-03-06 10:00:58 -08:00
2026-10-23 07:42:11 -10: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-04-16 21:01:18 +02:00
2026-08-14 14:46:21 +02:00
2026-11-05 21:55:50 -08:00
2026-09-11 18:30:29 +02:00
2026-10-16 11:36:46 +02:00
2026-08-14 14:46:21 +02:00
2025-11-26 17:17:53 +01:00
2026-11-05 21:55:50 -08:00
2026-08-14 14:46:21 +02:00
2024-08-27 16:29:55 +02:00
2025-11-26 17:21:48 +01:00
2026-06-01 18:28:41 +02:00
2024-08-27 16:29:55 +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-11-05 21:55:50 -08:00
2026-11-05 21:55:37 -08:00
2026-08-14 14:46:22 +02:00
2024-09-05 16:20:56 +02:00
2024-08-27 16:29:55 +02:00
2026-08-14 14:46:21 +02:00
2026-08-03 20:42:08 +02:00
2026-08-21 15:59:01 +02:00
2026-11-05 21:55:50 -08:00
2026-10-21 21:40:55 +02:00
2026-03-19 15:52:45 +01:00
2026-11-05 21:55:50 -08:00
2026-06-01 18:28:41 +02:00
2024-09-05 16:20:56 +02:00
2024-10-02 17:23:23 -04:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-06-03 14:18:18 +02: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-08-03 21:24:06 +02:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2026-10-16 11:36:47 +02:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2026-11-05 21:55:50 -08:00
2024-09-05 16:20:56 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-08-14 14:46:22 +02:00
2026-08-14 14:46:22 +02:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +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-11-05 21:55:50 -08:00
2026-10-16 10:21:52 +02:00
2024-08-27 16:29:55 +02:00
2026-02-21 17:09:51 -08:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2024-09-05 10:55:15 +02:00
2026-03-17 14:43:56 +01:00
2026-06-29 10:46:13 +02:00
2026-08-03 22:01:57 +02:00
2026-10-13 11:32:52 +02:00
2024-09-30 16:49:42 +01:00
2026-08-14 14:46:21 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-05-12 18:03:37 +02:00
2026-10-16 11:36:47 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-10-16 11:21:55 +02:00
2026-05-12 17:28:52 +02:00
2026-08-03 20:42:08 +02:00
2024-08-27 16:29:55 +02:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2025-06-17 10:44:13 +02:00
2026-10-15 17:59:31 +02:00
2026-06-29 11:16:26 +02:00
2026-10-15 17:59:31 +02:00
2026-10-15 17:59:31 +02:00
2026-10-15 17:59:31 +02:00
2026-02-21 17:09:51 -08:00
2026-10-15 17:59:31 +02:00
2026-10-15 17:59:31 +02:00
2026-10-15 17:59:31 +02:00
2026-10-15 18:38:33 +02:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2024-08-27 16:29:55 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2026-08-14 14:46:22 +02:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-09-22 10:30:17 -07:00
2026-11-05 21:55:50 -08:00
2024-08-27 16:29:55 +02:00
2026-02-21 17:09:51 -08:00
2026-08-19 09:27:26 +02:00
2025-02-03 22:59:42 +01: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
2025-10-14 12:01:34 +02:00
2024-12-02 11:34:44 -08:00
2025-10-14 12:01:34 +02:00
2025-10-14 12:01:34 +02:00
2026-11-05 21:55:50 -08:00
2026-09-23 18:46:49 +02:00
2024-09-05 16:20:57 +02:00
2026-05-12 18:03:37 +02:00
2026-11-05 21:55:50 -08:00
2024-09-05 16:20:57 +02:00
2024-09-05 16:20:57 +02:00
2026-10-16 10:14:06 +02:00
2026-10-16 10:14:06 +02:00
2026-10-16 10:14:06 +02:00
2026-10-16 10:14:06 +02:00
2026-09-11 16:15:42 +02:00
2024-09-05 16:20:57 +02:00
2026-08-14 14:46:21 +02:00
2026-11-05 21:55:50 -08:00
2026-02-21 17:09:51 -08:00
2026-10-21 21:40:55 +02:00
2026-10-21 21:40:55 +02:00
2026-06-10 20:32:07 +02:00
2026-11-05 21:55:50 -08:00
2026-10-21 21:30:38 +02:00
2026-09-11 15:47:03 +02:00
2026-09-14 14:45:33 +02:00