IB/ucm: utilize new cdev_device_add helper function
authorJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Fri, 17 Mar 2017 18:48:15 +0000 (12:48 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Mar 2017 05:44:33 +0000 (06:44 +0100)
commita0d78193dcf2bfa7c3d169c55a7a30a5a89fca7a
tree1b2c23c01c1a415cf4bad27b0e30d2e6cae3b074
parent1c1d152cc5ac3a67d199728a9ba0b4f54a498f8b
IB/ucm: utilize new cdev_device_add helper function

The use after free is not triggerable here because the cdev holds
the module lock and the only device_unregister is only triggered by
module unload, however make the change for consistency.

To make this work the cdev_del needs to move out of the struct device
release function.

This cleans up the error path significantly and thus also fixes a minor
bug where the devnum would not be released if cdev_add failed.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/ucm.c