err = ext4_ext_correct_indexes(handle, inode, path);
 
        /*
-        * Free the partial cluster only if the current extent does not
-        * reference it. Otherwise we might free used cluster.
+        * If there's a partial cluster and at least one extent remains in
+        * the leaf, free the partial cluster if it isn't shared with the
+        * current extent.  If there's a partial cluster and no extents
+        * remain in the leaf, it can't be freed here.  It can only be
+        * freed when it's possible to determine if it's not shared with
+        * any other extent - when the next leaf is processed or when space
+        * removal is complete.
         */
-       if (*partial_cluster > 0 &&
+       if (*partial_cluster > 0 && eh->eh_entries &&
            (EXT4_B2C(sbi, ext4_ext_pblock(ex) + ex_ee_len - 1) !=
             *partial_cluster)) {
                int flags = get_default_free_blocks_flags(inode);