Commit 039d713a authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/umad: Do not check status of nonseekable_open()

As the comment block of nonseekable_open() describes, nonseekable_open()
can never fail. Several places in kernel depend on this behavior.
Therefore, simplify the umad module to depend on this basic kernel
functionality.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent ee848721
...@@ -957,19 +957,22 @@ static int ib_umad_open(struct inode *inode, struct file *filp) ...@@ -957,19 +957,22 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
{ {
struct ib_umad_port *port; struct ib_umad_port *port;
struct ib_umad_file *file; struct ib_umad_file *file;
int ret = -ENXIO; int ret = 0;
port = container_of(inode->i_cdev, struct ib_umad_port, cdev); port = container_of(inode->i_cdev, struct ib_umad_port, cdev);
mutex_lock(&port->file_mutex); mutex_lock(&port->file_mutex);
if (!port->ib_dev) if (!port->ib_dev) {
ret = -ENXIO;
goto out; goto out;
}
ret = -ENOMEM; file = kzalloc(sizeof(*file), GFP_KERNEL);
file = kzalloc(sizeof *file, GFP_KERNEL); if (!file) {
if (!file) ret = -ENOMEM;
goto out; goto out;
}
mutex_init(&file->mutex); mutex_init(&file->mutex);
spin_lock_init(&file->send_lock); spin_lock_init(&file->send_lock);
...@@ -982,13 +985,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp) ...@@ -982,13 +985,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
list_add_tail(&file->port_list, &port->file_list); list_add_tail(&file->port_list, &port->file_list);
ret = nonseekable_open(inode, filp); nonseekable_open(inode, filp);
if (ret) {
list_del(&file->port_list);
kfree(file);
goto out;
}
out: out:
mutex_unlock(&port->file_mutex); mutex_unlock(&port->file_mutex);
return ret; return ret;
...@@ -1070,16 +1067,9 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp) ...@@ -1070,16 +1067,9 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
filp->private_data = port; filp->private_data = port;
ret = nonseekable_open(inode, filp); nonseekable_open(inode, filp);
if (ret)
goto err_clr_sm_cap;
return 0; return 0;
err_clr_sm_cap:
swap(props.set_port_cap_mask, props.clr_port_cap_mask);
ib_modify_port(port->ib_dev, port->port_num, 0, &props);
err_up_sem: err_up_sem:
up(&port->sm_sem); up(&port->sm_sem);
...@@ -1278,12 +1268,12 @@ static void ib_umad_kill_port(struct ib_umad_port *port) ...@@ -1278,12 +1268,12 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
mutex_unlock(&port->file_mutex); mutex_unlock(&port->file_mutex);
cdev_device_del(&port->sm_cdev, &port->sm_dev); cdev_device_del(&port->sm_cdev, &port->sm_dev);
/* balances device_initialize() */
put_device(&port->sm_dev);
cdev_device_del(&port->cdev, &port->dev); cdev_device_del(&port->cdev, &port->dev);
ida_free(&umad_ida, port->dev_num);
/* balances device_initialize() */ /* balances device_initialize() */
put_device(&port->sm_dev);
put_device(&port->dev); put_device(&port->dev);
ida_free(&umad_ida, port->dev_num);
} }
static void ib_umad_add_one(struct ib_device *device) static void ib_umad_add_one(struct ib_device *device)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment