ref: 10dd1d4f9b5097a5b96523093caeb97181d78c76
parent: f8a78f6905a92060f8bc3284e1e69a4a71fcf97f
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Wed Oct 28 09:23:53 EDT 2015
Don't access those checksum fields if metadata_csum is not enabled.
--- a/lwext4/ext4_balloc.c
+++ b/lwext4/ext4_balloc.c
@@ -108,6 +108,9 @@
uint32_t checksum = ext4_balloc_bitmap_csum(sb, bitmap);
uint16_t lo_checksum = to_le16(checksum & 0xFFFF),
hi_checksum = to_le16(checksum >> 16);
+
+ if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
+ return;
/* See if we need to assign a 32bit checksum */
bg->block_bitmap_csum_lo = lo_checksum;
@@ -122,14 +125,13 @@
struct ext4_bgroup *bg,
void *bitmap __unused)
{
-
- if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- return true;
-
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_balloc_bitmap_csum(sb, bitmap);
uint16_t lo_checksum = to_le16(checksum & 0xFFFF),
hi_checksum = to_le16(checksum >> 16);
+
+ if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
+ return true;
if (bg->block_bitmap_csum_lo != lo_checksum)
return false;
--- a/lwext4/ext4_ialloc.c
+++ b/lwext4/ext4_ialloc.c
@@ -117,6 +117,9 @@
uint16_t lo_checksum = to_le16(checksum & 0xFFFF),
hi_checksum = to_le16(checksum >> 16);
+ if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
+ return;
+
/* See if we need to assign a 32bit checksum */
bg->inode_bitmap_csum_lo = lo_checksum;
if (desc_size == EXT4_MAX_BLOCK_GROUP_DESCRIPTOR_SIZE)
@@ -131,13 +134,13 @@
void *bitmap __unused)
{
- if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
- return true;
-
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_ialloc_bitmap_csum(sb, bitmap);
uint16_t lo_checksum = to_le16(checksum & 0xFFFF),
hi_checksum = to_le16(checksum >> 16);
+
+ if (!ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM))
+ return true;
if (bg->inode_bitmap_csum_lo != lo_checksum)
return false;