summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/uverbs_marshall.c
diff options
context:
space:
mode:
authorDasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>2017-04-29 20:41:16 +0200
committerDoug Ledford <dledford@redhat.com>2017-05-01 20:32:43 +0200
commit4ba66093bdc6316cd2fe48e74a54bfc29599322f (patch)
tree88d7591433f9e9dc6a7e7b3aa734064c57d6ea16 /drivers/infiniband/core/uverbs_marshall.c
parentIB/core: Add braces when using sizeof (diff)
downloadlinux-4ba66093bdc6316cd2fe48e74a54bfc29599322f.tar.xz
linux-4ba66093bdc6316cd2fe48e74a54bfc29599322f.zip
IB/core: Check for global flag when using ah_attr
Read/write grh fields of the ah_attr only if the ah_flags field has the IB_AH_GRH bit enabled Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Don Hiatt <don.hiatt@intel.com> Reviewed-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/core/uverbs_marshall.c')
-rw-r--r--drivers/infiniband/core/uverbs_marshall.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/infiniband/core/uverbs_marshall.c b/drivers/infiniband/core/uverbs_marshall.c
index ed3e68f915ca..a9739f334562 100644
--- a/drivers/infiniband/core/uverbs_marshall.c
+++ b/drivers/infiniband/core/uverbs_marshall.c
@@ -36,17 +36,19 @@
void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
struct ib_ah_attr *src)
{
- memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof(src->grh.dgid));
- dst->grh.flow_label = src->grh.flow_label;
- dst->grh.sgid_index = src->grh.sgid_index;
- dst->grh.hop_limit = src->grh.hop_limit;
- dst->grh.traffic_class = src->grh.traffic_class;
memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
dst->dlid = src->dlid;
dst->sl = src->sl;
dst->src_path_bits = src->src_path_bits;
dst->static_rate = src->static_rate;
dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
+ if (dst->is_global) {
+ memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof(src->grh.dgid));
+ dst->grh.flow_label = src->grh.flow_label;
+ dst->grh.sgid_index = src->grh.sgid_index;
+ dst->grh.hop_limit = src->grh.hop_limit;
+ dst->grh.traffic_class = src->grh.traffic_class;
+ }
dst->port_num = src->port_num;
dst->reserved = 0;
}