Revision 0f53994f

b/target-i386/kvm.c
660 660
static int kvm_put_xsave(CPUState *env)
661 661
{
662 662
#ifdef KVM_CAP_XSAVE
663
    int i;
663
    int i, r;
664 664
    struct kvm_xsave* xsave;
665 665
    uint16_t cwd, swd, twd, fop;
666 666

  
......
685 685
    *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV] = env->xstate_bv;
686 686
    memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs,
687 687
            sizeof env->ymmh_regs);
688
    return kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
688
    r = kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
689
    qemu_free(xsave);
690
    return r;
689 691
#else
690 692
    return kvm_put_fpu(env);
691 693
#endif
......
850 852

  
851 853
    xsave = qemu_memalign(4096, sizeof(struct kvm_xsave));
852 854
    ret = kvm_vcpu_ioctl(env, KVM_GET_XSAVE, xsave);
853
    if (ret < 0)
855
    if (ret < 0) {
856
        qemu_free(xsave);
854 857
        return ret;
858
    }
855 859

  
856 860
    cwd = (uint16_t)xsave->region[0];
857 861
    swd = (uint16_t)(xsave->region[0] >> 16);
......
870 874
    env->xstate_bv = *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV];
871 875
    memcpy(env->ymmh_regs, &xsave->region[XSAVE_YMMH_SPACE],
872 876
            sizeof env->ymmh_regs);
877
    qemu_free(xsave);
873 878
    return 0;
874 879
#else
875 880
    return kvm_get_fpu(env);

Also available in: Unified diff