If user attach private data for AF_IB, the first byte will
be overwritten, because we always set the cma version no matter
family is AF_IB, so move the version set inside if condition.

Reported-by: Fabian Holler <[email protected]>
Signed-off-by: Jack Wang <[email protected]>
---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index d570030..22a22e2 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct 
rdma_id_private *id_priv)
        struct cma_hdr *cma_hdr;
 
        cma_hdr = hdr;
-       cma_hdr->cma_version = CMA_VERSION;
        if (cma_family(id_priv) == AF_INET) {
                struct sockaddr_in *src4, *dst4;
 
+               cma_hdr->cma_version = CMA_VERSION;
                src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
                dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);
 
@@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct 
rdma_id_private *id_priv)
        } else if (cma_family(id_priv) == AF_INET6) {
                struct sockaddr_in6 *src6, *dst6;
 
+               cma_hdr->cma_version = CMA_VERSION;
                src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
                dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to