summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXichao Zhao <zhao.xichao@vivo.com>2025-08-29 17:15:10 +0800
committerChristian Brauner <brauner@kernel.org>2025-08-29 12:00:58 +0200
commit38d1227fa71d96b470172df50e241775a802a8e7 (patch)
tree2733573bbe7c7e7b6fd3b0759b80037cc1ee3b2c
parentec6f613ef376410753173f8236bad5f07a86503a (diff)
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>
-rw-r--r--fs/ioctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 0248cb8db2d3..83d07218b6cd 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -426,7 +426,7 @@ static int ioctl_file_dedupe_range(struct file *file,
goto out;
}
- size = offsetof(struct file_dedupe_range, info[count]);
+ size = struct_size(same, info, count);
if (size > PAGE_SIZE) {
ret = -ENOMEM;
goto out;