Message ID | 1467735023-21942-1-git-send-email-monis@mellanox.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Tue, Jul 5, 2016 at 7:10 PM, Moni Shoua <monis@mellanox.com> wrote: > From: Leon Romanovsky <leon@kernel.org> > > Simplify rxe_init_ports and remove double free. > > Fixes: 0784481b2f32 ('Add initialization for Soft RoCE driver, pools constants etc.') same > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > Signed-off-by: Leon Romanovsky <leon@kernel.org> -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 7/5/2016 5:53 PM, Or Gerlitz wrote: > On Tue, Jul 5, 2016 at 7:10 PM, Moni Shoua <monis@mellanox.com> wrote: >> From: Leon Romanovsky <leon@kernel.org> >> >> Simplify rxe_init_ports and remove double free. >> >> Fixes: 0784481b2f32 ('Add initialization for Soft RoCE driver, pools constants etc.') > > same > >> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> >> Signed-off-by: Leon Romanovsky <leon@kernel.org> Applied, and squashed into original patch.
diff --git a/drivers/infiniband/hw/rxe/rxe.c b/drivers/infiniband/hw/rxe/rxe.c index 48c41e00..d49418b 100644 --- a/drivers/infiniband/hw/rxe/rxe.c +++ b/drivers/infiniband/hw/rxe/rxe.c @@ -165,42 +165,25 @@ static int rxe_init_port_param(struct rxe_port *port) */ static int rxe_init_ports(struct rxe_dev *rxe) { - int err; - struct rxe_port *port; - - port = &rxe->port; + struct rxe_port *port = &rxe->port; rxe_init_port_param(port); - if (!port->attr.pkey_tbl_len) { - err = -EINVAL; - goto err1; - } + if (!port->attr.pkey_tbl_len || !port->attr.gid_tbl_len) + return -EINVAL; port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len, sizeof(*port->pkey_tbl), GFP_KERNEL); - if (!port->pkey_tbl) { - err = -ENOMEM; - goto err1; - } - port->pkey_tbl[0] = 0xffff; - - if (!port->attr.gid_tbl_len) { - kfree(port->pkey_tbl); - err = -EINVAL; - goto err1; - } + if (!port->pkey_tbl) + return -ENOMEM; + port->pkey_tbl[0] = 0xffff; port->port_guid = rxe->ifc_ops->port_guid(rxe); spin_lock_init(&port->port_lock); return 0; - -err1: - kfree(port->pkey_tbl); - return err; } /* init pools of managed objects */