RDMA/uverbs: Fix error unwind in ib_uverbs_add_one
authorJason Gunthorpe <jgg@mellanox.com>
Mon, 17 Sep 2018 21:44:46 +0000 (15:44 -0600)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 19 Sep 2018 16:49:22 +0000 (10:49 -0600)
commit0099103926b68e6675a1be4644848f5b1c1b6f97
tree7be7fffe0221da2320629c9f3c086cb73f27b8fe
parent0965cc953a235196b8d6ef0cba45ecb5c355194f
RDMA/uverbs: Fix error unwind in ib_uverbs_add_one

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.

While we are here consolidate all the uvdev_dev init that cannot fail at
the top.

Fixes: c5c4d92e70f3 ("RDMA/uverbs: Use cdev_device_add() instead of cdev_add()")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
drivers/infiniband/core/uverbs_main.c