Commit 81c3a772 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: uart: properly interpret receive data size

In gb_uart_request_recv(), the receive data size is in little-endian
format.  Do the proper byte swapping of that value before using it.
Found by "make check".
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 8bd0ae6e
......@@ -78,6 +78,7 @@ static int gb_uart_request_recv(u8 type, struct gb_operation *op)
struct gb_uart_recv_data_request *receive_data;
struct gb_uart_serial_state_request *serial_state;
struct tty_port *port = &gb_tty->port;
u16 recv_data_size;
int count;
int ret = 0;
......@@ -85,15 +86,16 @@ static int gb_uart_request_recv(u8 type, struct gb_operation *op)
case GB_UART_TYPE_RECEIVE_DATA:
receive_data = request->payload;
count = gb_tty->buffer_payload_max - sizeof(*receive_data);
if (!receive_data->size || receive_data->size > count)
recv_data_size = le16_to_cpu(receive_data->size);
if (!recv_data_size || recv_data_size > count)
return -EINVAL;
count = tty_insert_flip_string(port, receive_data->data,
receive_data->size);
if (count != receive_data->size) {
recv_data_size);
if (count != recv_data_size) {
dev_err(&connection->dev,
"UART: RX 0x%08x bytes only wrote 0x%08x\n",
receive_data->size, count);
recv_data_size, count);
}
if (count)
tty_flip_buffer_push(port);
......
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