IB/ipoib: Clean error paths in add port
Refactor error paths in ipoib_add_port() function. The code flow
ensures that the function terminates on every error flow and it makes
redundant all "else" cases.
The functions are called during the flow are returning "result < 0", in
case of error, so there is no need to check it explicitly.
Fixes: 58e9cc90cd
("IB/IPoIB: Fix bad error flow in ipoib_add_port()")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:

committed by
Leon Romanovsky

parent
eb54714ddc
commit
dc892e17bb
@@ -2175,14 +2175,14 @@ static struct net_device *ipoib_add_port(const char *format,
|
|||||||
priv->dev->dev_id = port - 1;
|
priv->dev->dev_id = port - 1;
|
||||||
|
|
||||||
result = ib_query_port(hca, port, &attr);
|
result = ib_query_port(hca, port, &attr);
|
||||||
if (!result)
|
if (result) {
|
||||||
priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
|
|
||||||
else {
|
|
||||||
printk(KERN_WARNING "%s: ib_query_port %d failed\n",
|
printk(KERN_WARNING "%s: ib_query_port %d failed\n",
|
||||||
hca->name, port);
|
hca->name, port);
|
||||||
goto device_init_failed;
|
goto device_init_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
|
||||||
|
|
||||||
/* MTU will be reset when mcast join happens */
|
/* MTU will be reset when mcast join happens */
|
||||||
priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu);
|
priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu);
|
||||||
priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu;
|
priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu;
|
||||||
@@ -2213,12 +2213,14 @@ static struct net_device *ipoib_add_port(const char *format,
|
|||||||
printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
|
printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
|
||||||
hca->name, port, result);
|
hca->name, port, result);
|
||||||
goto device_init_failed;
|
goto device_init_failed;
|
||||||
} else
|
}
|
||||||
memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid));
|
|
||||||
|
memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw,
|
||||||
|
sizeof(union ib_gid));
|
||||||
set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
|
set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
|
||||||
|
|
||||||
result = ipoib_dev_init(priv->dev, hca, port);
|
result = ipoib_dev_init(priv->dev, hca, port);
|
||||||
if (result < 0) {
|
if (result) {
|
||||||
printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n",
|
printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n",
|
||||||
hca->name, port, result);
|
hca->name, port, result);
|
||||||
goto device_init_failed;
|
goto device_init_failed;
|
||||||
|
Reference in New Issue
Block a user