On Mon, Jun 12, 2023 at 02:49:02AM -0700, Selvin Xavier wrote: > +static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *attrs) > +{ > + struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs, BNXT_RE_ALLOC_PAGE_HANDLE); > + enum bnxt_re_alloc_page_type alloc_type; > + struct bnxt_re_user_mmap_entry *entry; > + enum bnxt_re_mmap_flag mmap_flag; > + struct bnxt_qplib_chip_ctx *cctx; > + struct bnxt_re_ucontext *uctx; > + struct bnxt_re_dev *rdev; > + u64 mmap_offset; > + u32 length; > + u32 dpi; > + u64 dbr; > + int err; > + > + uctx = container_of(ib_uverbs_get_ucontext(attrs), struct bnxt_re_ucontext, ib_uctx); > + if (IS_ERR(uctx)) > + return PTR_ERR(uctx); > + > + err = uverbs_get_const(&alloc_type, attrs, BNXT_RE_ALLOC_PAGE_TYPE); > + if (err) > + return err; > + > + rdev = uctx->rdev; > + cctx = rdev->chip_ctx; > + > + switch (alloc_type) { > + case BNXT_RE_ALLOC_WC_PAGE: > + if (cctx->modes.db_push) { > + if (bnxt_qplib_alloc_dpi(&rdev->qplib_res, &uctx->wcdpi, > + uctx, BNXT_QPLIB_DPI_TYPE_WC)) > + return -ENOMEM; > + length = PAGE_SIZE; > + dpi = uctx->wcdpi.dpi; > + dbr = (u64)uctx->wcdpi.umdbr; > + mmap_flag = BNXT_RE_MMAP_WC_DB; > + } else { > + return -EINVAL; > + } > + > + break; > + > + default: > + return -EOPNOTSUPP; > + } > + > + entry = bnxt_re_mmap_entry_insert(uctx, dbr, mmap_flag, &mmap_offset); > + if (IS_ERR(entry)) > + return PTR_ERR(entry); > + > + uobj->object = entry; > + uverbs_finalize_uobj_create(attrs, BNXT_RE_ALLOC_PAGE_HANDLE); uverbs_finalize_uobj_create() is supposed to be called once the function cannot fail anymore > + err = uverbs_copy_to(attrs, BNXT_RE_ALLOC_PAGE_MMAP_OFFSET, > + &mmap_offset, sizeof(mmap_offset)); > + if (err) > + return err; Because there is no way to undo it on error. So the error handling here needs adjusting Jason