@@ -215,14 +215,14 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
struct extent_buffer *leaf;
struct page *page;
struct btrfs_path *path;
- u32 *checksums = NULL, *crc;
+ u32 *crc = NULL;
char *disk_crcs = NULL;
struct btrfs_key key;
struct list_head bitmaps;
u64 num_entries;
u64 num_bitmaps;
u64 generation;
- u32 cur_crc = ~(u32)0;
+ u32 cur_crc;
pgoff_t index = 0;
unsigned long first_page_offset;
int num_checksums;
@@ -298,11 +298,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
/* Setup everything for doing checksumming */
num_checksums = i_size_read(inode) / PAGE_CACHE_SIZE;
- checksums = crc = kzalloc(sizeof(u32) * num_checksums, GFP_NOFS);
- if (!checksums)
- goto out;
first_page_offset = (sizeof(u32) * num_checksums) + sizeof(u64);
- disk_crcs = kzalloc(first_page_offset, GFP_NOFS);
+ disk_crcs = kzalloc(num_checksums, GFP_NOFS);
if (!disk_crcs)
goto out;
@@ -352,7 +349,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
if (index == 0) {
u64 *gen;
- memcpy(disk_crcs, addr, first_page_offset);
+ memcpy(disk_crcs, addr, num_checksums);
gen = addr + (sizeof(u32) * num_checksums);
if (*gen != BTRFS_I(inode)->generation) {
printk(KERN_ERR "btrfs: space cache generation"
@@ -467,7 +464,6 @@ next:
ret = 1;
out:
- kfree(checksums);
kfree(disk_crcs);
iput(inode);
return ret;