On Tue, Jun 16, 2020 at 01:58:13PM +0300, Leon Romanovsky wrote: > diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c > index 38de4942c682..16b86635d752 100644 > +++ b/drivers/infiniband/core/rdma_core.c > @@ -470,40 +470,41 @@ static struct ib_uobject * > alloc_begin_fd_uobject(const struct uverbs_api_object *obj, > struct uverbs_attr_bundle *attrs) > { > - const struct uverbs_obj_fd_type *fd_type = > - container_of(obj->type_attrs, struct uverbs_obj_fd_type, type); > + const struct uverbs_obj_fd_type *fd_type; > int new_fd; > struct ib_uobject *uobj; > struct file *filp; > > + uobj = alloc_uobj(attrs, obj); > + if (IS_ERR(uobj)) > + return uobj; > + > + fd_type = > + container_of(obj->type_attrs, struct uverbs_obj_fd_type, type); > if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release && > - fd_type->fops->release != &uverbs_async_event_release)) > + fd_type->fops->release != &uverbs_async_event_release)) { > + uverbs_uobject_put(uobj); > return ERR_PTR(-EINVAL); > + } I feel like this is a bit cleaner with a goto unwind ? Jason