aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2017-07-13 06:34:19 -0400
committerLeon Romanovsky <leon@kernel.org>2017-07-23 02:45:11 -0400
commitdc892e17bbae670a3d7aa6ab8bd1033b15b24645 (patch)
tree1441e6ccfd65cb68053401e1e5090e108e818b5c
parenteb54714ddcb2462d4d4b8aa78d028b61e217a835 (diff)
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: 58e9cc90cda7 ("IB/IPoIB: Fix bad error flow in ipoib_add_port()") Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 24fa87fe0952..6c77df34869d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -2175,14 +2175,14 @@ static struct net_device *ipoib_add_port(const char *format,
2175 priv->dev->dev_id = port - 1; 2175 priv->dev->dev_id = port - 1;
2176 2176
2177 result = ib_query_port(hca, port, &attr); 2177 result = ib_query_port(hca, port, &attr);
2178 if (!result) 2178 if (result) {
2179 priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
2180 else {
2181 printk(KERN_WARNING "%s: ib_query_port %d failed\n", 2179 printk(KERN_WARNING "%s: ib_query_port %d failed\n",
2182 hca->name, port); 2180 hca->name, port);
2183 goto device_init_failed; 2181 goto device_init_failed;
2184 } 2182 }
2185 2183
2184 priv->max_ib_mtu = ib_mtu_enum_to_int(attr.max_mtu);
2185
2186 /* MTU will be reset when mcast join happens */ 2186 /* MTU will be reset when mcast join happens */
2187 priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); 2187 priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu);
2188 priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; 2188 priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu;
@@ -2213,12 +2213,14 @@ static struct net_device *ipoib_add_port(const char *format,
2213 printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n", 2213 printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
2214 hca->name, port, result); 2214 hca->name, port, result);
2215 goto device_init_failed; 2215 goto device_init_failed;
2216 } else 2216 }
2217 memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw, sizeof (union ib_gid)); 2217
2218 memcpy(priv->dev->dev_addr + 4, priv->local_gid.raw,
2219 sizeof(union ib_gid));
2218 set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags); 2220 set_bit(IPOIB_FLAG_DEV_ADDR_SET, &priv->flags);
2219 2221
2220 result = ipoib_dev_init(priv->dev, hca, port); 2222 result = ipoib_dev_init(priv->dev, hca, port);
2221 if (result < 0) { 2223 if (result) {
2222 printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n", 2224 printk(KERN_WARNING "%s: failed to initialize port %d (ret = %d)\n",
2223 hca->name, port, result); 2225 hca->name, port, result);
2224 goto device_init_failed; 2226 goto device_init_failed;