diff options
| author | Gustavo A. R. Silva <[email protected]> | 2020-06-09 01:22:33 +0000 |
|---|---|---|
| committer | Kees Cook <[email protected]> | 2020-06-17 03:45:08 +0000 |
| commit | b19d57d0f3cc6f1022edf94daf1d70506a09e3c2 (patch) | |
| tree | c0bf158b81e425eeb159a12dd173a421cf7ddef1 /tools/perf/scripts/python/check-perf-trace.py | |
| parent | Linux 5.8-rc1 (diff) | |
| download | kernel-b19d57d0f3cc6f1022edf94daf1d70506a09e3c2.tar.gz kernel-b19d57d0f3cc6f1022edf94daf1d70506a09e3c2.zip | |
overflow.h: Add flex_array_size() helper
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 <[email protected]>
Link: https://lore.kernel.org/r/20200609012233.GA3371@embeddedor
Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/check-perf-trace.py')
0 files changed, 0 insertions, 0 deletions
