Re: [PATCH 2/2] devres: Provide kmalloc_obj*-style API for devm_kmalloc

From: Linus Torvalds

Date: Thu Nov 12 2026 - 13:30:14 EST


On Thu, 12 Nov 2026 at 09:09, Kees Cook <kees@xxxxxxxxxx> wrote:
>
> One thing Justin was poking at was adding a "strict" mode to typedef

Honestly, the sparse setup is superior. It does that 'strict' thing
(except it calls it 'nocast') _and_ it has 'bitwise' that is a nocast
that also disallows non-bit type checks (which is *very* useful for
things like "this is a big-endian value: you can only do bitwise
checks against other big-endian values).

So the compiler addition may be worth it, but even the "poking at" is
weaker than what sparse already does.

And the 'struct' model is honestly superior to both when it works -
but can add extra overhead (but can also end up being nicer than both:
instead of casting with special "I really mean it" casts, you can
derefence the struct and get its value that way)

Linus