Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: qrtr: fix endian handling of confirm_rx field

Convert confirm_rx to little endian when enqueueing and convert it back on
receive. This fixes control flow on big endian hosts, little endian is
unaffected.

On transmit, store confirm_rx as __le32 using cpu_to_le32(). On receive,
apply le32_to_cpu() before using the value. !! ensures the value is 0 or 1
in native endianness, so the conversion isn’t strictly required here, but
it is kept for consistency and clarity.

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alexander Wilhelm and committed by
David S. Miller
e4cf6087 55299429

+2 -2
+2 -2
net/qrtr/af_qrtr.c
··· 365 365 } 366 366 367 367 hdr->size = cpu_to_le32(len); 368 - hdr->confirm_rx = !!confirm_rx; 368 + hdr->confirm_rx = cpu_to_le32(!!confirm_rx); 369 369 370 370 rc = skb_put_padto(skb, ALIGN(len, 4) + sizeof(*hdr)); 371 371 ··· 466 466 cb->type = le32_to_cpu(v1->type); 467 467 cb->src_node = le32_to_cpu(v1->src_node_id); 468 468 cb->src_port = le32_to_cpu(v1->src_port_id); 469 - cb->confirm_rx = !!v1->confirm_rx; 469 + cb->confirm_rx = !!le32_to_cpu(v1->confirm_rx); 470 470 cb->dst_node = le32_to_cpu(v1->dst_node_id); 471 471 cb->dst_port = le32_to_cpu(v1->dst_port_id); 472 472