提交 7f29aded 编写于 作者: G Greg Kroah-Hartman

greybus: uart: properly calculate max buffer size

We forgot to count the size of the uart send data message header when
calculating the maximum size of the buffer that the uart driver could
send in one chunk.

This fixes the math and makes the variable a size_t to match the return
value of the call to gb_operation_get_payload_size_max();
Reported-by: NAxel Haslam <ahaslam@baylibre.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@google.com>
Tested-by: NAxel Haslam <ahaslam@baylibre.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@google.com>
上级 737df280
...@@ -43,7 +43,7 @@ struct gb_tty_line_coding { ...@@ -43,7 +43,7 @@ struct gb_tty_line_coding {
struct gb_tty { struct gb_tty {
struct tty_port port; struct tty_port port;
void *buffer; void *buffer;
u32 buffer_payload_max; size_t buffer_payload_max;
struct gb_connection *connection; struct gb_connection *connection;
u16 cport_id; u16 cport_id;
unsigned int minor; unsigned int minor;
...@@ -608,11 +608,8 @@ static int gb_uart_connection_init(struct gb_connection *connection) ...@@ -608,11 +608,8 @@ static int gb_uart_connection_init(struct gb_connection *connection)
} }
gb_tty->buffer_payload_max = gb_tty->buffer_payload_max =
gb_operation_get_payload_size_max(connection); gb_operation_get_payload_size_max(connection) -
if (!gb_tty->buffer_payload_max) { sizeof(struct gb_uart_send_data_request);
retval = -EINVAL;
goto error_payload;
}
gb_tty->buffer = kzalloc(gb_tty->buffer_payload_max, GFP_KERNEL); gb_tty->buffer = kzalloc(gb_tty->buffer_payload_max, GFP_KERNEL);
if (!gb_tty->buffer) { if (!gb_tty->buffer) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册