> +int pcs_reg_mr(struct pcs_mr_set *mrs, u64 start, u64 len)
> +{
> +     int ret = 0;
> +     struct pcs_mr *mr;
> +     struct pcs_umem *umem;
> +
> +     if (!len)
> +             return -EINVAL;
> +
> +     if (!can_do_mlock())
> +             return -EPERM;
> +
> +     if (atomic_inc_return(&mrs->mr_num) > PCS_MAX_MR) {
> +             atomic_dec(&mrs->mr_num);
> +             return -ENOMEM;
> +     }
> +
> +     umem = pcs_umem_get(start, len);
> +     if (IS_ERR(umem))

Is atomic_dec(&mrs->mr_num) lost here?

> +             return PTR_ERR(umem);
> +
> +     mr = kzalloc(sizeof(*mr), GFP_KERNEL);
> +     if (!mr) {
> +             ret = -ENOMEM;
> +             goto err_out;
> +     }
> +
> +     mr->mrs = mrs;
> +     mr->va = start;
> +     mr->len = len;
> +     mr->umem = umem;
> +     kref_init(&mr->ref);
> +
> +     ret = xa_alloc_cyclic(&mrs->mr_xa, &mr->id, mr,
> +                     XA_LIMIT(1, PCS_MAX_MR), &mrs->mr_next, GFP_KERNEL);
> +     if (ret < 0) {
> +             kfree(mr);
> +             goto err_out;
> +     }
> +
> +     mr->id_valid = 1;
> +
> +     return mr->id;
> +
> +err_out:
> +     pcs_umem_release(umem);
> +     atomic_dec(&mrs->mr_num);
> +     return ret;
> +}

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to