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