Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: Replace offsetof() with struct_size() in ioctl_file_dedupe_range()

When dealing with structures containing flexible arrays, struct_size()
provides additional compile-time checks compared to offsetof(). This
enhances code robustness and reduces the risk of potential errors.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
Link: https://lore.kernel.org/20250829091510.597858-1-zhao.xichao@vivo.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Xichao Zhao and committed by
Christian Brauner
38d1227f ec6f613e

+1 -1
+1 -1
fs/ioctl.c
··· 426 426 goto out; 427 427 } 428 428 429 - size = offsetof(struct file_dedupe_range, info[count]); 429 + size = struct_size(same, info, count); 430 430 if (size > PAGE_SIZE) { 431 431 ret = -ENOMEM; 432 432 goto out;