aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDulshani Gunawardhana <dulshani.gunawardhana89@gmail.com>2013-10-31 01:02:18 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-11 22:12:22 -0500
commitd9b0d9ba04cf99abff9125b688c03e154598a644 (patch)
tree19d5fd9776a761379a89a1f87e452973bd9685a1 /fs
parente248e04e7798d234ddbeab6ee6acdec2476fe1a8 (diff)
btrfs: Replace kmalloc with kmalloc_array
Replace kmalloc(size * nr, ) with kmalloc_array(nr, size), thus making it easier to check is that the calculation doesn't wrap or return a smaller allocation Signed-off-by: Dulshani Gunawardhana <dulshani.gunawardhana89@gmail.com> Reviewed-by: Zach Brown <zab@redhat.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/delayed-inode.c4
-rw-r--r--fs/btrfs/ioctl.c2
-rw-r--r--fs/btrfs/super.c2
-rw-r--r--fs/btrfs/volumes.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 2bb8e1a988a1..8d292fbae659 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -770,13 +770,13 @@ static int btrfs_batch_insert_items(struct btrfs_root *root,
770 */ 770 */
771 btrfs_set_path_blocking(path); 771 btrfs_set_path_blocking(path);
772 772
773 keys = kmalloc(sizeof(struct btrfs_key) * nitems, GFP_NOFS); 773 keys = kmalloc_array(nitems, sizeof(struct btrfs_key), GFP_NOFS);
774 if (!keys) { 774 if (!keys) {
775 ret = -ENOMEM; 775 ret = -ENOMEM;
776 goto out; 776 goto out;
777 } 777 }
778 778
779 data_size = kmalloc(sizeof(u32) * nitems, GFP_NOFS); 779 data_size = kmalloc_array(nitems, sizeof(u32), GFP_NOFS);
780 if (!data_size) { 780 if (!data_size) {
781 ret = -ENOMEM; 781 ret = -ENOMEM;
782 goto error; 782 goto error;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 78d20482b72a..3712ef86ca82 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1198,7 +1198,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
1198 ra = &file->f_ra; 1198 ra = &file->f_ra;
1199 } 1199 }
1200 1200
1201 pages = kmalloc(sizeof(struct page *) * max_cluster, 1201 pages = kmalloc_array(max_cluster, sizeof(struct page *),
1202 GFP_NOFS); 1202 GFP_NOFS);
1203 if (!pages) { 1203 if (!pages) {
1204 ret = -ENOMEM; 1204 ret = -ENOMEM;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c9079db7441e..1de6d4d67431 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1470,7 +1470,7 @@ static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
1470 nr_devices = fs_info->fs_devices->open_devices; 1470 nr_devices = fs_info->fs_devices->open_devices;
1471 BUG_ON(!nr_devices); 1471 BUG_ON(!nr_devices);
1472 1472
1473 devices_info = kmalloc(sizeof(*devices_info) * nr_devices, 1473 devices_info = kmalloc_array(nr_devices, sizeof(*devices_info),
1474 GFP_NOFS); 1474 GFP_NOFS);
1475 if (!devices_info) 1475 if (!devices_info)
1476 return -ENOMEM; 1476 return -ENOMEM;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3c16da51348f..0db637097862 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4901,7 +4901,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
4901 num_stripes = map->num_stripes; 4901 num_stripes = map->num_stripes;
4902 max_errors = nr_parity_stripes(map); 4902 max_errors = nr_parity_stripes(map);
4903 4903
4904 raid_map = kmalloc(sizeof(u64) * num_stripes, 4904 raid_map = kmalloc_array(num_stripes, sizeof(u64),
4905 GFP_NOFS); 4905 GFP_NOFS);
4906 if (!raid_map) { 4906 if (!raid_map) {
4907 ret = -ENOMEM; 4907 ret = -ENOMEM;