X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=drivers%2Finfiniband%2Fhw%2Fusnic%2Fusnic_ib_qp_grp.c;h=f8dfd76be89fbfdcb94559ed58cda9a3d8c591b2;hb=614cd4a4ac3daf725508e372bce2160e2d8039a9;hp=7ecc6061f1f4d5f915edb0e3994b2dcdc327de83;hpb=10ffe3dbf7f9c63d6fde3d1fe23b8fd2ae4d7bd1;p=~andy%2Flinux diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c index 7ecc6061f1f..f8dfd76be89 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c @@ -629,6 +629,7 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow, { enum usnic_transport_type trans_type = qp_flow->trans_type; int err; + uint16_t port_num = 0; switch (trans_type) { case USNIC_TRANSPORT_ROCE_CUSTOM: @@ -637,9 +638,15 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow, case USNIC_TRANSPORT_IPV4_UDP: err = usnic_transport_sock_get_addr(qp_flow->udp.sock, NULL, NULL, - (uint16_t *) id); + &port_num); if (err) return err; + /* + * Copy port_num to stack first and then to *id, + * so that the short to int cast works for little + * and big endian systems. + */ + *id = port_num; break; default: usnic_err("Unsupported transport %u\n", trans_type);