From 746e0ef95ade8dd6d8633679a87ab573b5e1f69e Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Wed, 3 Dec 2014 12:27:45 -0600 Subject: [PATCH] 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: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/operation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 6a1d3e663547..6197167a67d8 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -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; /* -- 2.39.5