summaryrefslogtreecommitdiff
path: root/fs/btrfs/send.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-04-11 19:52:02 +0300
committerDavid Sterba <dsterba@suse.com>2016-05-06 16:22:49 +0300
commite55d1153dbf48485a74eb4bf4eefeaedcf1486a9 (patch)
tree065e2631cdd79aceb825ea9c7bcd5db500d4ae9b /fs/btrfs/send.c
parenteb5b75fe2e61a9ba907785b70318736112b0cf93 (diff)
downloadlinux-e55d1153dbf48485a74eb4bf4eefeaedcf1486a9.tar.xz
btrfs: send: use temporary variable to store allocation size
We're going to use the argument multiple times later. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r--fs/btrfs/send.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 4e950ebbef53..4f85a47c2f55 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -5939,6 +5939,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
u32 i;
u64 *clone_sources_tmp = NULL;
int clone_sources_to_rollback = 0;
+ unsigned alloc_size;
int sort_clone_roots = 0;
int index;
@@ -6050,24 +6051,25 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
sctx->waiting_dir_moves = RB_ROOT;
sctx->orphan_dirs = RB_ROOT;
- sctx->clone_roots = vzalloc(sizeof(struct clone_root) *
- (arg->clone_sources_count + 1));
+ alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
+
+ sctx->clone_roots = vzalloc(alloc_size);
if (!sctx->clone_roots) {
ret = -ENOMEM;
goto out;
}
+ alloc_size = arg->clone_sources_count * sizeof(*arg->clone_sources);
+
if (arg->clone_sources_count) {
- clone_sources_tmp = vmalloc(arg->clone_sources_count *
- sizeof(*arg->clone_sources));
+ clone_sources_tmp = vmalloc(alloc_size);
if (!clone_sources_tmp) {
ret = -ENOMEM;
goto out;
}
ret = copy_from_user(clone_sources_tmp, arg->clone_sources,
- arg->clone_sources_count *
- sizeof(*arg->clone_sources));
+ alloc_size);
if (ret) {
ret = -EFAULT;
goto out;