]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
greybus: operation: allocate response before setting result
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 1 Jul 2015 10:37:30 +0000 (12:37 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 1 Jul 2015 23:54:44 +0000 (16:54 -0700)
Make sure to allocate a response message before setting the operation
result.

This is needed to handle cancellation of incoming operations.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/operation.c

index d6e1db87e30ac44eda226e19cc97fb3a3e4db431..881dddc51abd8f24fadd21e613e08cec62d4e598 100644 (file)
@@ -662,6 +662,12 @@ static int gb_operation_response_send(struct gb_operation *operation,
        struct gb_connection *connection = operation->connection;
        int ret;
 
+       if (!operation->response &&
+                       !gb_operation_is_unidirectional(operation)) {
+               if (!gb_operation_response_alloc(operation, 0))
+                       return -ENOMEM;
+       }
+
        /* Record the result */
        if (!gb_operation_result_set(operation, errno)) {
                dev_err(&connection->dev, "request result already set\n");
@@ -672,11 +678,6 @@ static int gb_operation_response_send(struct gb_operation *operation,
        if (gb_operation_is_unidirectional(operation))
                return 0;
 
-       if (!operation->response) {
-               if (!gb_operation_response_alloc(operation, 0))
-                       return -ENOMEM;
-       }
-
        /* Reference will be dropped when message has been sent. */
        gb_operation_get(operation);