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>
This commit is contained in:
Johan Hovold 2015-07-09 15:18:01 +02:00 committed by Greg Kroah-Hartman
parent 048a7ffe27
commit e4340b13fd
1 changed files with 3 additions and 2 deletions

View File

@ -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);
}