]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: operation: fix cancellation of responses
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 1 Jul 2015 10:37:31 +0000 (12:37 +0200)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 1 Jul 2015 23:54:44 +0000 (16:54 -0700)
An operation with a response in-flight will already have set the
operation result and would therefore never be cancelled by the current
implementation.

Note that the reference taken when sending the result will be dropped
in the message completion callback.

Also note that an incoming, non-unidirectional messages will always have
an allocated response if its result has been set.

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

index 881dddc51abd8f24fadd21e613e08cec62d4e598..9e2ff7dd278ac07eba850fc8b4460130e36bba7a 100644 (file)
@@ -845,9 +845,10 @@ void gb_operation_cancel(struct gb_operation *operation, int errno)
 {
        if (gb_operation_result_set(operation, errno)) {
                gb_message_cancel(operation->request);
-               if (operation->response)
-                       gb_message_cancel(operation->response);
                gb_operation_put(operation);
+       } else if (gb_operation_is_incoming(operation)) {
+               if (!gb_operation_is_unidirectional(operation))
+                       gb_message_cancel(operation->response);
        }
 }
 EXPORT_SYMBOL_GPL(gb_operation_cancel);