ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max
[linux-2.6-microblaze.git] / fs / ext4 / ext4_extents.h
index 1c216fc..44e5988 100644 (file)
@@ -170,10 +170,13 @@ struct partial_cluster {
        (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
 #define EXT_LAST_INDEX(__hdr__) \
        (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
-#define EXT_MAX_EXTENT(__hdr__) \
-       (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
+#define EXT_MAX_EXTENT(__hdr__)        \
+       ((le16_to_cpu((__hdr__)->eh_max)) ? \
+       ((EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) \
+                                       : 0)
 #define EXT_MAX_INDEX(__hdr__) \
-       (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
+       ((le16_to_cpu((__hdr__)->eh_max)) ? \
+       ((EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) : 0)
 
 static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
 {