summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/uart.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@google.com>2016-02-22 18:14:46 -0800
committerGreg Kroah-Hartman <gregkh@google.com>2016-02-23 22:25:08 -0800
commit7f29aded453e0392391b831c196583c274ec2cfd (patch)
tree2eda536314f3d3bd47c2e167237cca7b24a96786 /drivers/staging/greybus/uart.c
parent737df280a73b9e9d3d24cd8e81637b0496f06dde (diff)
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: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/uart.c')
-rw-r--r--drivers/staging/greybus/uart.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 46cce8c82412..52cc9d581ca4 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -43,7 +43,7 @@ struct gb_tty_line_coding {
struct gb_tty {
struct tty_port port;
void *buffer;
- u32 buffer_payload_max;
+ size_t buffer_payload_max;
struct gb_connection *connection;
u16 cport_id;
unsigned int minor;
@@ -608,11 +608,8 @@ static int gb_uart_connection_init(struct gb_connection *connection)
}
gb_tty->buffer_payload_max =
- gb_operation_get_payload_size_max(connection);
- if (!gb_tty->buffer_payload_max) {
- retval = -EINVAL;
- goto error_payload;
- }
+ gb_operation_get_payload_size_max(connection) -
+ sizeof(struct gb_uart_send_data_request);
gb_tty->buffer = kzalloc(gb_tty->buffer_payload_max, GFP_KERNEL);
if (!gb_tty->buffer) {