gpt_h->header_crc32 = cpu_to_le32(calc_crc32);
 
        if (dev_desc->block_write(dev_desc->dev,
-                                 le32_to_cpu(gpt_h->last_usable_lba + 1),
+                                 le32_to_cpu(gpt_h->last_usable_lba) + 1,
                                  pte_blk_cnt, gpt_e) != pte_blk_cnt)
                goto err;
 
 {
        u32 offset = (u32)le32_to_cpu(gpt_h->first_usable_lba);
        ulong start;
+       u32 last_usable_lba = (u32)le32_to_cpu(gpt_h->last_usable_lba);
        int i, k;
        size_t efiname_len, dosname_len;
 #ifdef CONFIG_PARTITION_UUIDS
                        gpt_e[i].starting_lba = cpu_to_le64(offset);
                        offset += partitions[i].size;
                }
-               if (offset >= gpt_h->last_usable_lba) {
+               if (offset >= last_usable_lba) {
                        printf("Partitions layout exceds disk size\n");
                        return -1;
                }