ret = PTR_ERR(qp);
                goto err_put;
        }
+       ib_qp_usecnt_inc(qp);
 
        obj->uevent.uobject.object = qp;
        obj->uevent.event_file = READ_ONCE(attrs->ufile->default_async_file);
 
                ret = PTR_ERR(qp);
                goto err_put;
        }
+       ib_qp_usecnt_inc(qp);
 
        if (attr.qp_type == IB_QPT_XRC_TGT) {
                obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object,
 
        if (ret)
                goto err_security;
 
-       ib_qp_usecnt_inc(qp);
        rdma_restrack_add(&qp->res);
        return qp;
 
        if (IS_ERR(qp))
                return qp;
 
+       ib_qp_usecnt_inc(qp);
+
        if (qp_init_attr->cap.max_rdma_ctxs) {
                ret = rdma_rw_init_mrs(qp, qp_init_attr);
                if (ret)