On Mon, Sep 17, 2018 at 03:44:46PM -0600, Jason Gunthorpe wrote: > The error path has several mistakes > > - cdev_del should not be called if cdev_device_add fails > - We must call put_device on all the goto exit paths > as that is what frees the uapi, SRCU and the struct itself. > > Fixes: c5c4d92e70f3 ("RDMA/uverbs: Use cdev_device_add() instead of cdev_add()") > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx> > drivers/infiniband/core/uverbs_main.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > Parav, yes? > > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c > index 16e5f714ca536e..ed8db441adb90e 100644 > +++ b/drivers/infiniband/core/uverbs_main.c > @@ -1031,6 +1031,11 @@ static void ib_uverbs_add_one(struct ib_device *device) > return; > } > > + device_initialize(&uverbs_dev->dev); > + uverbs_dev->dev.class = uverbs_class; > + uverbs_dev->dev.parent = device->dev.parent; > + uverbs_dev->dev.release = ib_uverbs_release_dev; > + > atomic_set(&uverbs_dev->refcount, 1); > init_completion(&uverbs_dev->comp); > uverbs_dev->xrcd_tree = RB_ROOT; > @@ -1055,11 +1060,7 @@ static void ib_uverbs_add_one(struct ib_device *device) > if (ib_uverbs_create_uapi(device, uverbs_dev)) > goto err_uapi; > > - device_initialize(&uverbs_dev->dev); > - uverbs_dev->dev.class = uverbs_class; > - uverbs_dev->dev.parent = device->dev.parent; > uverbs_dev->dev.devt = base; > - uverbs_dev->dev.release = ib_uverbs_release_dev; > uverbs_dev->groups[0] = &dev_attr_group; > uverbs_dev->dev.groups = uverbs_dev->groups; > dev_set_name(&uverbs_dev->dev, "uverbs%d", uverbs_dev->devnum); I moved more of the lines that can't fail up to the top and applied this to for-next Thanks, Jason