static void bnxt_re_check_and_set_relaxed_ordering(struct bnxt_re_dev *rdev,
                                                   struct bnxt_qplib_mrw *qplib_mr)
 {
-       if (_is_relaxed_ordering_supported(rdev->dev_attr.dev_cap_flags2) &&
+       if (_is_relaxed_ordering_supported(rdev->dev_attr->dev_cap_flags2) &&
            pcie_relaxed_ordering_enabled(rdev->en_dev->pdev))
                qplib_mr->flags |= CMDQ_REGISTER_MR_FLAGS_ENABLE_RO;
 }
                         struct ib_udata *udata)
 {
        struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
 
        memset(ib_attr, 0, sizeof(*ib_attr));
        memcpy(&ib_attr->fw_ver, dev_attr->fw_ver,
                       struct ib_port_attr *port_attr)
 {
        struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
        int rc;
 
        memset(port_attr, 0, sizeof(*port_attr));
        struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
 
        snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d.%d",
-                rdev->dev_attr.fw_ver[0], rdev->dev_attr.fw_ver[1],
-                rdev->dev_attr.fw_ver[2], rdev->dev_attr.fw_ver[3]);
+                rdev->dev_attr->fw_ver[0], rdev->dev_attr->fw_ver[1],
+                rdev->dev_attr->fw_ver[2], rdev->dev_attr->fw_ver[3]);
 }
 
 int bnxt_re_query_pkey(struct ib_device *ibdev, u32 port_num,
        mr->qplib_mr.pd = &pd->qplib_pd;
        mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR;
        mr->qplib_mr.access_flags = __from_ib_access_flags(mr_access_flags);
-       if (!_is_alloc_mr_unified(rdev->dev_attr.dev_cap_flags)) {
+       if (!_is_alloc_mr_unified(rdev->dev_attr->dev_cap_flags)) {
                rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
                if (rc) {
                        ibdev_err(&rdev->ibdev, "Failed to alloc fence-HW-MR\n");
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
        sq = &qplqp->sq;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        align = sizeof(struct sq_send_hdr);
        ilsize = ALIGN(init_attr->cap.max_inline_data, align);
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
        rq = &qplqp->rq;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        if (init_attr->srq) {
                struct bnxt_re_srq *srq;
 
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) {
                qplqp->rq.max_sge = dev_attr->max_qp_sges;
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
        sq = &qplqp->sq;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        sq->max_sge = init_attr->cap.max_send_sge;
        entries = init_attr->cap.max_send_wr;
 
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) {
                entries = bnxt_re_init_depth(init_attr->cap.max_send_wr + 1, uctx);
 
        rdev = qp->rdev;
        qplqp = &qp->qplib_qp;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
 
        /* Setup misc params */
        ether_addr_copy(qplqp->smac, rdev->netdev->dev_addr);
        ib_pd = ib_qp->pd;
        pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
        rdev = pd->rdev;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
        qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
 
        uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
        ib_pd = ib_srq->pd;
        pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
        rdev = pd->rdev;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
        srq = container_of(ib_srq, struct bnxt_re_srq, ib_srq);
 
        if (srq_init_attr->attr.max_wr >= dev_attr->max_srq_wqes) {
 {
        struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
        struct bnxt_re_dev *rdev = qp->rdev;
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
        enum ib_qp_state curr_qp_state, new_qp_state;
        int rc, entries;
        unsigned int flags;
        struct ib_udata *udata = &attrs->driver_udata;
        struct bnxt_re_ucontext *uctx =
                rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
        struct bnxt_qplib_chip_ctx *cctx;
        int cqe = attr->cqe;
        int rc, entries;
 
        cq =  container_of(ibcq, struct bnxt_re_cq, ib_cq);
        rdev = cq->rdev;
-       dev_attr = &rdev->dev_attr;
+       dev_attr = rdev->dev_attr;
        if (!ibcq->uobject) {
                ibdev_err(&rdev->ibdev, "Kernel CQ Resize not supported");
                return -EOPNOTSUPP;
        mr->qplib_mr.access_flags = __from_ib_access_flags(mr_access_flags);
        mr->qplib_mr.type = CMDQ_ALLOCATE_MRW_MRW_FLAGS_MR;
 
-       if (!_is_alloc_mr_unified(rdev->dev_attr.dev_cap_flags)) {
+       if (!_is_alloc_mr_unified(rdev->dev_attr->dev_cap_flags)) {
                rc = bnxt_qplib_alloc_mrw(&rdev->qplib_res, &mr->qplib_mr);
                if (rc) {
                        ibdev_err(&rdev->ibdev, "Failed to allocate MR rc = %d", rc);
        struct bnxt_re_ucontext *uctx =
                container_of(ctx, struct bnxt_re_ucontext, ib_uctx);
        struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       struct bnxt_qplib_dev_attr *dev_attr = rdev->dev_attr;
        struct bnxt_re_user_mmap_entry *entry;
        struct bnxt_re_uctx_resp resp = {};
        struct bnxt_re_uctx_req ureq = {};
 
 
        if (!rdev->chip_ctx)
                return;
+
+       kfree(rdev->dev_attr);
+       rdev->dev_attr = NULL;
+
        chip_ctx = rdev->chip_ctx;
        rdev->chip_ctx = NULL;
        rdev->rcfw.res = NULL;
 {
        struct bnxt_qplib_chip_ctx *chip_ctx;
        struct bnxt_en_dev *en_dev;
-       int rc;
+       int rc = -ENOMEM;
 
        en_dev = rdev->en_dev;
 
 
        rdev->qplib_res.cctx = rdev->chip_ctx;
        rdev->rcfw.res = &rdev->qplib_res;
-       rdev->qplib_res.dattr = &rdev->dev_attr;
+       rdev->dev_attr = kzalloc(sizeof(*rdev->dev_attr), GFP_KERNEL);
+       if (!rdev->dev_attr)
+               goto free_chip_ctx;
+       rdev->qplib_res.dattr = rdev->dev_attr;
        rdev->qplib_res.is_vf = BNXT_EN_VF(en_dev);
        rdev->qplib_res.en_dev = en_dev;
 
 
        bnxt_re_set_db_offset(rdev);
        rc = bnxt_qplib_map_db_bar(&rdev->qplib_res);
-       if (rc) {
-               kfree(rdev->chip_ctx);
-               rdev->chip_ctx = NULL;
-               return rc;
-       }
+       if (rc)
+               goto free_dev_attr;
 
        if (bnxt_qplib_determine_atomics(en_dev->pdev))
                ibdev_info(&rdev->ibdev,
                           "platform doesn't support global atomics.");
        return 0;
+free_dev_attr:
+       kfree(rdev->dev_attr);
+       rdev->dev_attr = NULL;
+free_chip_ctx:
+       kfree(rdev->chip_ctx);
+       rdev->chip_ctx = NULL;
+       return rc;
 }
 
 /* SR-IOV helper functions */
        struct bnxt_qplib_ctx *ctx;
        int i;
 
-       attr = &rdev->dev_attr;
+       attr = rdev->dev_attr;
        ctx = &rdev->qplib_ctx;
 
        ctx->qpc_count = min_t(u32, BNXT_RE_MAX_QPC_COUNT,
        if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx))
                for (i = 0; i < MAX_TQM_ALLOC_REQ; i++)
                        rdev->qplib_ctx.tqm_ctx.qcount[i] =
-                       rdev->dev_attr.tqm_alloc_reqs[i];
+                       rdev->dev_attr->tqm_alloc_reqs[i];
 }
 
 static void bnxt_re_limit_vf_res(struct bnxt_qplib_ctx *qplib_ctx, u32 num_vf)
 
        /* Configure and allocate resources for qplib */
        rdev->qplib_res.rcfw = &rdev->rcfw;
-       rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr);
+       rc = bnxt_qplib_get_dev_attr(&rdev->rcfw);
        if (rc)
                goto fail;
 
-       rc = bnxt_qplib_alloc_res(&rdev->qplib_res, rdev->en_dev->pdev,
-                                 rdev->netdev, &rdev->dev_attr);
+       rc = bnxt_qplib_alloc_res(&rdev->qplib_res, rdev->netdev);
        if (rc)
                goto fail;
 
                        rdev->pacing.dbr_pacing = false;
                }
        }
-       rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr);
+       rc = bnxt_qplib_get_dev_attr(&rdev->rcfw);
        if (rc)
                goto disable_rcfw;