summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/operation.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-07-09 15:18:01 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2015-07-13 15:29:27 -0700
commite4340b13fd2cf9bcf1f0a40ae15de454ffdb74f8 (patch)
treef1ee5860175a2a613032f3a28e25ff97805f4d9e /drivers/staging/greybus/operation.c
parent048a7ffe274280c27fc572ba3ec7150eba6efc40 (diff)
greybus: operation: fix incoming-response corruption
Make sure not to update the response message buffer for an operation that is already scheduled for completion. Currently if we get two incoming responses with the same id, the second one would overwrite the response message buffer. Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> 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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c
index 85394624395e..b78c55fac8cc 100644
--- a/drivers/staging/greybus/operation.c
+++ b/drivers/staging/greybus/operation.c
@@ -796,11 +796,12 @@ static void gb_connection_recv_response(struct gb_connection *connection,
/* We must ignore the payload if a bad status is returned */
if (errno)
size = sizeof(*message->header);
- memcpy(message->header, data, size);
/* The rest will be handled in work queue context */
- if (gb_operation_result_set(operation, errno))
+ if (gb_operation_result_set(operation, errno)) {
+ memcpy(message->header, data, size);
queue_work(gb_operation_workqueue, &operation->work);
+ }
gb_operation_put(operation);
}