Commit fde7382b authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 1635304d
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment