summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/operation.c
diff options
context:
space:
mode:
authorJohan Hovold2015-07-01 12:37:30 +0200
committerGreg Kroah-Hartman2015-07-02 01:54:44 +0200
commitfde7382b47c5fbb64be81420d267f1e314cfee94 (patch)
tree5e7eeabba220e14627c3c82c43e6b8165840f231 /drivers/staging/greybus/operation.c
parentgreybus: operation: drop redundant oom message (diff)
downloadkernel-qcow2-linux-fde7382b47c5fbb64be81420d267f1e314cfee94.tar.gz
kernel-qcow2-linux-fde7382b47c5fbb64be81420d267f1e314cfee94.tar.xz
kernel-qcow2-linux-fde7382b47c5fbb64be81420d267f1e314cfee94.zip
greybus: operation: allocate response before setting result
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>
Diffstat (limited to 'drivers/staging/greybus/operation.c')
-rw-r--r--drivers/staging/greybus/operation.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index d6e1db87e30a..881dddc51abd 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -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);