Commit 746e0ef9 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: use null pointer for empty payload

Currently message->payload always points to the address immediately
following the header in a message.  If the payload length is 0, this
is not a valid pointer.

Change the code to assign a null pointer to the payload in this
case.  I have verified that no code dereferences the payload pointer
unless the payload is known to have non-zero size.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 7cfa6995
......@@ -284,7 +284,7 @@ static void gb_operation_message_init(struct greybus_host_device *hd,
header = (struct gb_operation_msg_hdr *)(buffer + hd->buffer_headroom);
message->header = header;
message->payload = header + 1;
message->payload = payload_size ? header + 1 : NULL;
message->payload_size = payload_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