On Sun, Jul 19, 2020 at 08:22:23AM +0300, Leon Romanovsky wrote: > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > The automatic object lifetime model allows us to change write() interface > to have same logic as ioctl() path. Update the create/alloc functions to be > in the following format, so code flow will be the same: > * Allocate objects > * Initialize them > * Call to the drivers, this is last step that is allowed to fail > * Finalize object > * Return response and allow to core code to handle abort/commit > respectively. > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > --- > drivers/infiniband/core/uverbs_cmd.c | 312 ++++++++------------------- > 1 file changed, 93 insertions(+), 219 deletions(-) > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c > index 68c9a0210220..a66fc3e37a74 100644 > --- a/drivers/infiniband/core/uverbs_cmd.c > +++ b/drivers/infiniband/core/uverbs_cmd.c > @@ -273,7 +273,7 @@ int ib_init_ucontext(struct uverbs_attr_bundle *attrs) > > static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs) > { > - struct ib_uverbs_get_context_resp resp; > + struct ib_uverbs_get_context_resp resp = {}; > struct ib_uverbs_get_context cmd; > struct ib_device *ib_dev; > struct ib_uobject *uobj; > @@ -293,25 +293,20 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs) > goto err_ucontext; > } > > - resp = (struct ib_uverbs_get_context_resp){ > - .num_comp_vectors = attrs->ufile->device->num_comp_vectors, > - .async_fd = uobj->id, > - }; > - ret = uverbs_response(attrs, &resp, sizeof(resp)); > - if (ret) > - goto err_uobj; > - > ret = ib_init_ucontext(attrs); > if (ret) > goto err_uobj; init_ucontext cannot be undone and cannot be called twice, so it must be last in the function. I dropped the hunk changing ib_uverbs_get_context(). Applied to for-next, thanks Jason