Skip to content

Commit

Permalink
IB/ehca: use correct destination for memcpy
Browse files Browse the repository at this point in the history
Using an element of a struct as the address for the memcpy of the whole
struct may introduce a buffer overflow and does not help readability either
simply pass the real thing as first argument to memcpy.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Nicholas Mc Guire authored and Doug Ledford committed May 11, 2015
1 parent b6b2bbe commit 94634e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/hw/ehca/ehca_mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int ehca_attach_mcast(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
return -EINVAL;
}

memcpy(&my_gid.raw, gid->raw, sizeof(union ib_gid));
memcpy(&my_gid, gid->raw, sizeof(union ib_gid));

subnet_prefix = be64_to_cpu(my_gid.global.subnet_prefix);
interface_id = be64_to_cpu(my_gid.global.interface_id);
Expand Down Expand Up @@ -114,7 +114,7 @@ int ehca_detach_mcast(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
return -EINVAL;
}

memcpy(&my_gid.raw, gid->raw, sizeof(union ib_gid));
memcpy(&my_gid, gid->raw, sizeof(union ib_gid));

subnet_prefix = be64_to_cpu(my_gid.global.subnet_prefix);
interface_id = be64_to_cpu(my_gid.global.interface_id);
Expand Down

0 comments on commit 94634e9

Please sign in to comment.