]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: qrtr: fix endian handling of confirm_rx field
authorAlexander Wilhelm <alexander.wilhelm@westermo.com>
Thu, 26 Mar 2026 07:17:52 +0000 (08:17 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Mar 2026 12:10:15 +0000 (12:10 +0000)
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>
net/qrtr/af_qrtr.c

index 55fd2dd375886f53a909496f4b85a99aefefe44d..bea1f1720e7f0f4b5a6406b344d730c04a363fc3 100644 (file)
@@ -365,7 +365,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
        }
 
        hdr->size = cpu_to_le32(len);
-       hdr->confirm_rx = !!confirm_rx;
+       hdr->confirm_rx = cpu_to_le32(!!confirm_rx);
 
        rc = skb_put_padto(skb, ALIGN(len, 4) + sizeof(*hdr));
 
@@ -466,7 +466,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)
                cb->type = le32_to_cpu(v1->type);
                cb->src_node = le32_to_cpu(v1->src_node_id);
                cb->src_port = le32_to_cpu(v1->src_port_id);
-               cb->confirm_rx = !!v1->confirm_rx;
+               cb->confirm_rx = !!le32_to_cpu(v1->confirm_rx);
                cb->dst_node = le32_to_cpu(v1->dst_node_id);
                cb->dst_port = le32_to_cpu(v1->dst_port_id);