summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2015-12-30 16:14:18 +0200
committerDoug Ledford <dledford@redhat.com>2016-01-19 15:26:54 -0500
commit9506902b7be2d8ccc235c14ccaec7f07b2c7d520 (patch)
tree196b87a189b9d2bf91a9ba52bbf5f6b059559e11 /drivers
parent2e2cdace5a26507a564d319a1338920a838ef52e (diff)
IB/core: Fix dereference before check
Sparse complains about dereference before check. Fixing this by moving the check before the dereference. Fixes: 200298326b27 ('IB/core: Validate route when we init ah') Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/core/addr.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 0b5f24533ac1..791cc98475bb 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -497,13 +497,14 @@ int rdma_resolve_ip_route(struct sockaddr *src_addr,
struct sockaddr_storage ssrc_addr = {};
struct sockaddr *src_in = (struct sockaddr *)&ssrc_addr;
- if (src_addr->sa_family != dst_addr->sa_family)
- return -EINVAL;
+ if (src_addr) {
+ if (src_addr->sa_family != dst_addr->sa_family)
+ return -EINVAL;
- if (src_addr)
memcpy(src_in, src_addr, rdma_addr_size(src_addr));
- else
+ } else {
src_in->sa_family = dst_addr->sa_family;
+ }
return addr_resolve(src_in, dst_addr, addr, false);
}