Commit f809309a authored by Upinder Malhi's avatar Upinder Malhi Committed by Roland Dreier

IB/usnic: Fix smatch endianness error

Error reported at http://marc.info/?l=linux-rdma&m=138995755801039&w=2

Fix short to int cast for big endian systems.
Signed-off-by: default avatarUpinder Malhi <umalhi@cisco.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 38dbfb59
...@@ -629,6 +629,7 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow, ...@@ -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; enum usnic_transport_type trans_type = qp_flow->trans_type;
int err; int err;
uint16_t port_num = 0;
switch (trans_type) { switch (trans_type) {
case USNIC_TRANSPORT_ROCE_CUSTOM: case USNIC_TRANSPORT_ROCE_CUSTOM:
...@@ -637,9 +638,15 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow, ...@@ -637,9 +638,15 @@ static int qp_grp_id_from_flow(struct usnic_ib_qp_grp_flow *qp_flow,
case USNIC_TRANSPORT_IPV4_UDP: case USNIC_TRANSPORT_IPV4_UDP:
err = usnic_transport_sock_get_addr(qp_flow->udp.sock, err = usnic_transport_sock_get_addr(qp_flow->udp.sock,
NULL, NULL, NULL, NULL,
(uint16_t *) id); &port_num);
if (err) if (err)
return 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; break;
default: default:
usnic_err("Unsupported transport %u\n", trans_type); usnic_err("Unsupported transport %u\n", trans_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment