ovl: Replace offsetof() with struct_size() in ovl_stack_free()
PATCH 1/1 ovl: Replace offsetof() with struct_size() in ovl_stack_free()
Compared to offsetof(), struct_size() provides additional compile-time checks for structs with flexible arrays (e.g., __must_be_array()).
No functional changes intended.
Signed-off-by Thorsten Blum <[email protected]>
--- fs/overlayfs/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/util.c +2 -2
@@ -145,9 +145,9 @@ void ovl_stack_free(struct ovl_path *stack, unsigned int n)struct ovl_entry *ovl_alloc_entry (unsigned int numlower) { - size_t size = offsetof(struct ovl_entry, __lowerstack[numlower]); -struct ovl_entry *oe =kzalloc (size,GFP_KERNEL ); +struct ovl_entry *oe; + oe =kzalloc (struct_size (oe, __lowerstack, numlower),GFP_KERNEL );if (oe) oe->__numlower = numlower;
Signature · 1 line
2.49.0