]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: complete overflow responses
authorAlex Elder <elder@linaro.org>
Thu, 20 Nov 2014 21:37:07 +0000 (15:37 -0600)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 21 Nov 2014 20:18:38 +0000 (12:18 -0800)
If a response arrives for an operation request and the allotted
buffer isn't big enough we report the error, but we don't finish
processing the response.

Instead, set the operation result, but then finish processing
the response (no different from any other operation error).

This will allow the normal completion handling to occur for
this error case.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/operation.c

index 3e3fc73a881cc4490cc4210c17944f40b18f7c08..d91cd5b4b65aa423c1038e5c3b347fab6a156322 100644 (file)
@@ -526,16 +526,15 @@ static void gb_connection_recv_response(struct gb_connection *connection,
        gb_pending_operation_remove(operation);
 
        message = &operation->response;
-       if (size > message->buffer_size) {
-               operation->result = GB_OP_OVERFLOW;
+       if (size <= message->buffer_size) {
+               /* Transfer the operation result from the response header */
+               header = message->buffer;
+               operation->result = header->result;
+       } else {
                gb_connection_err(connection, "recv buffer too small");
-               return;         /* XXX Should still complete operation */
+               operation->result = GB_OP_OVERFLOW;
        }
 
-       /* The status in the response is the result of the operation */
-       header = message->buffer;
-       operation->result = header->result;
-
        /* We must ignore the payload if a bad status is returned */
        if (operation->result == GB_OP_SUCCESS)
                memcpy(message->buffer, data, size);