mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/5] malloc: add __free() cleanup handlers
@ 2026-09-22 10:47 Ahmad Fatoum
  2026-09-22 10:47 ` [PATCH 1/5] commands: rksecure: exit if invalid integer passed to -b Ahmad Fatoum
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-22 10:47 UTC (permalink / raw)
  To: barebox; +Cc: mfe, Ahmad Fatoum

The cleanup infrastructure was added to barebox a while back in
commit 332e3542e5ed ("Port Linux __cleanup() based guard
infrastructure"), but without any DEFINE_FREE() handlers, so nothing
could be passed to __free() so far.

Let's start with malloc and kmalloc, so buffers can be tied to the
scope they are used in:

	void *buf __free(free)  =  malloc(size);
	void *foo __free(kfree) = kzalloc(size, GFP_KERNEL);

[k]free_sensitive() looks up the usable size of the buffer before
zeroing it, so it gets the same test rather than just a NULL check
to avoid an error pointer dereference inside the allocator.

Ahmad Fatoum (5):
  commands: rksecure: exit if invalid integer passed to -b
  firmware-zynqmp: don't ignore the kstrtouint() result in parse_reg()
  include: compiler: make __must_check a yes-op
  malloc: add __free() cleanup handlers
  test: self: add cleanup selftest

 arch/arm/mach-zynqmp/firmware-zynqmp.c |  6 +-
 commands/rksecure.c                    |  4 +-
 include/linux/compiler_types.h         |  4 --
 include/linux/slab.h                   |  5 ++
 include/malloc.h                       |  5 ++
 test/self/Kconfig                      | 10 +++
 test/self/Makefile                     |  1 +
 test/self/cleanup.c                    | 89 ++++++++++++++++++++++++++
 8 files changed, 118 insertions(+), 6 deletions(-)
 create mode 100644 test/self/cleanup.c

-- 
2.47.3




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-23  6:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 10:47 [PATCH 0/5] malloc: add __free() cleanup handlers Ahmad Fatoum
2026-09-22 10:47 ` [PATCH 1/5] commands: rksecure: exit if invalid integer passed to -b Ahmad Fatoum
2026-09-22 10:47 ` [PATCH 2/5] firmware-zynqmp: don't ignore the kstrtouint() result in parse_reg() Ahmad Fatoum
2026-09-22 10:47 ` [PATCH 3/5] include: compiler: make __must_check a yes-op Ahmad Fatoum
2026-09-22 10:47 ` [PATCH 4/5] malloc: add __free() cleanup handlers Ahmad Fatoum
2026-09-22 10:47 ` [PATCH 5/5] test: self: add cleanup selftest Ahmad Fatoum
2026-09-23  6:33 ` [PATCH 0/5] malloc: add __free() cleanup handlers Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox