Commit 55f66a88 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: enforce non-zero operation type requirement

The operation type 0x00 is reserved as an explicitly invalid
operation type in all protocols.  Enforce this.

Add a check for callers who erroneously have the RESPONSE message
type flag set in the operation type passed in gb_operation_create().
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 64ce39a3
...@@ -455,10 +455,23 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing, ...@@ -455,10 +455,23 @@ gb_operation_create_common(struct gb_connection *connection, bool outgoing,
return NULL; return NULL;
} }
/*
* Create a new operation associated with the given connection. The
* request and response sizes provided are the number of bytes
* required to hold the request/response payload only. Both of
* these are allowed to be 0. Note that 0x00 is reserved as an
* invalid operation type for all protocols, and this is enforced
* here.
*/
struct gb_operation *gb_operation_create(struct gb_connection *connection, struct gb_operation *gb_operation_create(struct gb_connection *connection,
u8 type, size_t request_size, u8 type, size_t request_size,
size_t response_size) size_t response_size)
{ {
if (WARN_ON_ONCE(!type))
return NULL;
if (WARN_ON_ONCE(type & GB_OPERATION_TYPE_RESPONSE))
type &= ~GB_OPERATION_TYPE_RESPONSE;
return gb_operation_create_common(connection, true, type, return gb_operation_create_common(connection, true, type,
request_size, response_size); request_size, response_size);
} }
......
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