Skip to content

Commit 52eb678

Browse files
Ayush1325gregkh
authored andcommitted
greybus: gb-beagleplay: Ensure le for values in transport
Ensure that the following values are little-endian: - header->pad (which is used for cport_id) - header->size Fixes: ec558bb ("greybus: Add BeaglePlay Linux Driver") Reported-by: kernel test robot <yujie.liu@intel.com> Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com> Link: https://lore.kernel.org/r/20231203075312.255233-1-ayushdevel1325@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4181ef7 commit 52eb678

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/greybus/gb-beagleplay.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len)
9393
memcpy(&cport_id, hdr->pad, sizeof(cport_id));
9494

9595
dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received",
96-
hdr->operation_id, hdr->type, cport_id, hdr->result);
96+
hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result);
9797

98-
greybus_data_rcvd(bg->gb_hd, cport_id, buf, len);
98+
greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len);
9999
}
100100

101101
static void hdlc_rx_dbg_frame(const struct gb_beagleplay *bg, const char *buf, u16 len)
@@ -340,14 +340,15 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messa
340340
{
341341
struct gb_beagleplay *bg = dev_get_drvdata(&hd->dev);
342342
struct hdlc_payload payloads[2];
343+
__le16 cport_id = le16_to_cpu(cport);
343344

344345
dev_dbg(&hd->dev, "Sending greybus message with Operation %u, Type: %X on Cport %u",
345346
msg->header->operation_id, msg->header->type, cport);
346347

347-
if (msg->header->size > RX_HDLC_PAYLOAD)
348+
if (le16_to_cpu(msg->header->size) > RX_HDLC_PAYLOAD)
348349
return dev_err_probe(&hd->dev, -E2BIG, "Greybus message too big");
349350

350-
memcpy(msg->header->pad, &cport, sizeof(cport));
351+
memcpy(msg->header->pad, &cport_id, sizeof(cport_id));
351352

352353
payloads[0].buf = msg->header;
353354
payloads[0].len = sizeof(*msg->header);

0 commit comments

Comments
 (0)