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
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:37 -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-08-31 11:26:28 -04: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-08-31 11:26:29 -04: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-08-31 11:26:29 -04:00
2026-11-05 21:55:50 -08:00
2026-08-31 11:26:30 -04:00
2026-09-18 18:25:40 -04: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-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-08-31 11:29:39 -04:00
2026-11-05 21:55:37 -08:00
2026-08-31 11:29:39 -04: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-20 17:32:54 +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
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-08-17 09:28:13 -07:00
2026-08-31 11:29:40 -04:00
2026-06-29 13:18:50 -04:00
2026-09-03 14:03:09 -04:00
2026-09-29 12:47:55 -04: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-04-28 18:59:22 -07:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-02-22 08:26:33 -08:00
2026-07-28 11:25:29 -04:00
2026-11-05 21:55:37 -08:00
2026-11-05 21:55:50 -08:00
2026-08-17 09:28:16 -07:00
2026-06-29 13:18:50 -04:00
2026-06-29 13:18:50 -04:00
2026-11-05 21:55:50 -08:00
2026-11-05 21:55:50 -08:00
2026-09-17 11:23:30 -04:00
2026-07-17 10:09:56 +02:00
2026-02-21 17:09:51 -08:00
2026-08-31 11:26:29 -04: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-08-31 11:26:29 -04: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-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-17 11:23:30 -04:00
2026-06-29 13:23:00 -04:00
2026-02-21 17:09:51 -08:00
2026-08-31 11:26:29 -04:00
2026-08-31 11:26:30 -04: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-23 17:16:23 -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-06-29 13:16:17 -04:00
2026-11-05 21:55:50 -08:00
2026-06-29 13:16:17 -04: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-08-31 11:29:39 -04:00
2026-08-31 11:29:39 -04: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-08-31 11:29:39 -04:00
2026-11-05 21:55:50 -08:00
2026-08-31 11:29:39 -04:00
2026-09-29 12:47:55 -04:00
2026-09-01 07:12:49 -04:00
2026-09-01 07:12:49 -04:00
2026-10-26 19:45:50 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-09-29 12:47:55 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-06-29 13:16:17 -04:00
2026-09-03 14:03:09 -04:00
2026-10-26 19:45:49 -04:00