From: Dmitry Antipov Date: Thu, 21 Dec 2023 08:47:45 +0000 (+0300) Subject: btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send() X-Git-Tag: accepted/tizen/unified/toolchain/20240610.172841^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c6699f21346842a6da031cc50ac3b4117b5d1ea;p=platform%2Fkernel%2Flinux-starfive.git btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send() 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 (cherry picked from commit 6ff09b6b8c2fb6b3edda4ffaa173153a40653067) Signed-off-by: Jaehoon Chung Change-Id: I30403a32f70d9760f2ce200f8195b87ad62baf4e --- diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index db94eefda27e..c367b1f0fc0b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -8205,8 +8205,8 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg) goto out; } - 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;