IB/core: Add missing check for addr_resolve callback return value
authorMark Bloch <markb@mellanox.com>
Thu, 27 Oct 2016 13:36:29 +0000 (16:36 +0300)
committerDoug Ledford <dledford@redhat.com>
Thu, 17 Nov 2016 01:03:44 +0000 (20:03 -0500)
When calling rdma_resolve_ip inside rdma_addr_find_l2_eth_by_grh,
the return status of the request was ignored in the callback function
causing a successful return and an empty dmac.

Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Alex Vesker <valex@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/addr.c

index b136d3acc5bde63f5af8d43f16af3d3107a6db05..0f58f46dbad7e0b4059cbab4ffca95623cad8bb9 100644 (file)
@@ -699,13 +699,16 @@ EXPORT_SYMBOL(rdma_addr_cancel);
 struct resolve_cb_context {
        struct rdma_dev_addr *addr;
        struct completion comp;
+       int status;
 };
 
 static void resolve_cb(int status, struct sockaddr *src_addr,
             struct rdma_dev_addr *addr, void *context)
 {
-       memcpy(((struct resolve_cb_context *)context)->addr, addr, sizeof(struct
-                               rdma_dev_addr));
+       if (!status)
+               memcpy(((struct resolve_cb_context *)context)->addr,
+                      addr, sizeof(struct rdma_dev_addr));
+       ((struct resolve_cb_context *)context)->status = status;
        complete(&((struct resolve_cb_context *)context)->comp);
 }
 
@@ -743,6 +746,10 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
 
        wait_for_completion(&ctx.comp);
 
+       ret = ctx.status;
+       if (ret)
+               return ret;
+
        memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN);
        dev = dev_get_by_index(&init_net, dev_addr.bound_dev_if);
        if (!dev)