Revision bf81507d

b/block/vmdk.c
842 842
                uint64_t offset,
843 843
                bool allocate)
844 844
{
845
    /* 128 sectors * 512 bytes each = grain size 64KB */
846
    uint8_t  whole_grain[extent->cluster_sectors * 512];
845
    int ret = VMDK_OK;
846
    uint8_t *whole_grain = NULL;
847 847

  
848 848
    /* we will be here if it's first write on non-exist grain(cluster).
849 849
     * try to read from parent image, if exist */
850 850
    if (bs->backing_hd) {
851
        int ret;
852

  
851
        whole_grain =
852
            qemu_blockalign(bs, extent->cluster_sectors << BDRV_SECTOR_BITS);
853 853
        if (!vmdk_is_cid_valid(bs)) {
854
            return VMDK_ERROR;
854
            ret = VMDK_ERROR;
855
            goto exit;
855 856
        }
856 857

  
857 858
        /* floor offset to cluster */
......
859 860
        ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain,
860 861
                extent->cluster_sectors);
861 862
        if (ret < 0) {
862
            return VMDK_ERROR;
863
            ret = VMDK_ERROR;
864
            goto exit;
863 865
        }
864 866

  
865 867
        /* Write grain only into the active image */
866 868
        ret = bdrv_write(extent->file, cluster_offset, whole_grain,
867 869
                extent->cluster_sectors);
868 870
        if (ret < 0) {
869
            return VMDK_ERROR;
871
            ret = VMDK_ERROR;
872
            goto exit;
870 873
        }
871 874
    }
872
    return VMDK_OK;
875
exit:
876
    qemu_vfree(whole_grain);
877
    return ret;
873 878
}
874 879

  
875 880
static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data)

Also available in: Unified diff