android_kernel_motorola_sm6375/include
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Gustavo A. R. Silva 60f05081e0 overflow.h: Add flex_array_size() helper
commit b19d57d0f3cc6f1022edf94daf1d70506a09e3c2 upstream.

Add flex_array_size() helper for the calculation of the size, in bytes,
of a flexible array member contained within an enclosing structure.

Example of usage:

struct something {
	size_t count;
	struct foo items[];
};

struct something *instance;

instance = kmalloc(struct_size(instance, items, count), GFP_KERNEL);
instance->count = count;
memcpy(instance->items, src, flex_array_size(instance, items, instance->count));

The helper returns SIZE_MAX on overflow instead of wrapping around.

Additionally replaces parameter "n" with "count" in struct_size() helper
for greater clarity and unification.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200609012233.GA3371@embeddedor
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-04 13:14:50 +02:00
..
acpi
asm-generic
clocksource
crypto
drm drm: Don't treat 0 as -1 in drm_fixp2int_ceil 2024-03-26 18:22:19 -04:00
dt-bindings
keys
kvm
linux overflow.h: Add flex_array_size() helper 2024-09-04 13:14:50 +02:00
math-emu
media media: rename VFL_TYPE_GRABBER to _VIDEO 2024-03-26 18:22:22 -04:00
misc
net netfilter: nf_tables: use timestamp to check for set element timeout 2024-08-19 05:33:53 +02:00
pcmcia
ras
rdma
scsi
soc soc: fsl: qbman: Add CGR update function 2024-04-13 12:51:27 +02:00
sound
target
trace SUNRPC: Fixup gss_status tracepoint error output 2024-08-19 05:33:32 +02:00
uapi m68k: amiga: Turn off Warp1260 interrupts during boot 2024-08-19 05:33:36 +02:00
vdso
video
xen