On Tue, Jan 22, 2019 at 08:31:20AM +0200, Leon Romanovsky wrote: > From: Parav Pandit <parav@xxxxxxxxxxxx> > > As the comment block of nonseekable_open() describes, nonseekable_open() > can never fail. Several places in kernel depend on this behavior. > Therefore, simplify umad module to depend on this basic kernel > functionality. > > Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx> > --- > drivers/infiniband/core/user_mad.c | 30 ++++++++++-------------------- > 1 file changed, 10 insertions(+), 20 deletions(-) > > diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c > index 097f153f0f22..b0909f75d9e4 100644 > --- a/drivers/infiniband/core/user_mad.c > +++ b/drivers/infiniband/core/user_mad.c > @@ -957,19 +957,22 @@ static int ib_umad_open(struct inode *inode, struct file *filp) > { > struct ib_umad_port *port; > struct ib_umad_file *file; > - int ret = -ENXIO; > + int ret = 0; > > port = container_of(inode->i_cdev, struct ib_umad_port, cdev); > > mutex_lock(&port->file_mutex); > > - if (!port->ib_dev) > + if (!port->ib_dev) { > + ret = -ENXIO; > goto out; > + } > > - ret = -ENOMEM; > - file = kzalloc(sizeof *file, GFP_KERNEL); > - if (!file) > + file = kzalloc(sizeof(*file), GFP_KERNEL); > + if (!file) { > + ret = -ENOMEM; > goto out; > + } > > mutex_init(&file->mutex); > spin_lock_init(&file->send_lock); > @@ -982,13 +985,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp) > > list_add_tail(&file->port_list, &port->file_list); > > - ret = nonseekable_open(inode, filp); > - if (ret) { > - list_del(&file->port_list); > - kfree(file); > - goto out; > - } > - > + nonseekable_open(inode, filp); > out: > mutex_unlock(&port->file_mutex); > return ret; > @@ -1070,16 +1067,9 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp) > > filp->private_data = port; > > - ret = nonseekable_open(inode, filp); > - if (ret) > - goto err_clr_sm_cap; > - > + nonseekable_open(inode, filp); > 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: > up(&port->sm_sem); > > -- > 2.19.1 >