From 43c6e6b86bcdfd0611784d5ab682b78aaa0980ea Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 13 May 2024 12:09:56 +0200 Subject: [PATCH] 5.10-stable patches added patches: btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch --- ...-arguments-order-in-btrfs_ioctl_send.patch | 43 +++++++++++++++++++ queue-5.10/series | 1 + 2 files changed, 44 insertions(+) create mode 100644 queue-5.10/btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch diff --git a/queue-5.10/btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch b/queue-5.10/btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch new file mode 100644 index 00000000000..d1c277a2920 --- /dev/null +++ b/queue-5.10/btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch @@ -0,0 +1,43 @@ +From 6ff09b6b8c2fb6b3edda4ffaa173153a40653067 Mon Sep 17 00:00:00 2001 +From: Dmitry Antipov +Date: Thu, 21 Dec 2023 11:47:45 +0300 +Subject: btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send() + +From: Dmitry Antipov + +commit 6ff09b6b8c2fb6b3edda4ffaa173153a40653067 upstream. + +When compiling with gcc version 14.0.0 20231220 (experimental) +and W=1, I've noticed the following warning: + +fs/btrfs/send.c: In function 'btrfs_ioctl_send': +fs/btrfs/send.c:8208:44: warning: 'kvcalloc' sizes specified with 'sizeof' +in the earlier argument and not in the later argument [-Wcalloc-transposed-args] + 8208 | sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots), + | ^ + +Since 'n' and 'size' arguments of 'kvcalloc()' are multiplied to +calculate the final size, their actual order doesn't affect the result +and so this is not a bug. But it's still worth to fix it. + +Signed-off-by: Dmitry Antipov +Reviewed-by: David Sterba +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/send.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/fs/btrfs/send.c ++++ b/fs/btrfs/send.c +@@ -7339,8 +7339,8 @@ long btrfs_ioctl_send(struct file *mnt_f + sctx->waiting_dir_moves = RB_ROOT; + sctx->orphan_dirs = RB_ROOT; + +- sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots), +- arg->clone_sources_count + 1, ++ sctx->clone_roots = kvcalloc(arg->clone_sources_count + 1, ++ sizeof(*sctx->clone_roots), + GFP_KERNEL); + if (!sctx->clone_roots) { + ret = -ENOMEM; diff --git a/queue-5.10/series b/queue-5.10/series index fda11fc3eec..01b2b5407b7 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -88,3 +88,4 @@ kcov-remove-kcov-include-from-sched.h-and-move-it-to.patch net-bridge-fix-corrupted-ethernet-header-on-multicas.patch ipv6-fib6_rules-avoid-possible-null-dereference-in-f.patch net-hns3-use-appropriate-barrier-function-after-sett.patch +btrfs-fix-kvcalloc-arguments-order-in-btrfs_ioctl_send.patch -- 2.47.2