From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 1C3EC1C4118 for ; Wed, 30 Aug 2017 17:37:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 18F072F266 for ; Wed, 30 Aug 2017 17:37:27 +0000 (UTC) Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v2xWzj7wk6Fv for ; Wed, 30 Aug 2017 17:37:26 +0000 (UTC) Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0073.outbound.protection.outlook.com [104.47.37.73]) by silver.osuosl.org (Postfix) with ESMTPS id 232FB2E71F for ; Wed, 30 Aug 2017 17:37:26 +0000 (UTC) From: David Kershner Subject: [PATCH 17/28] staging: unisys: Change data to point to visor_controlvm_parameters_header. Date: Wed, 30 Aug 2017 13:36:24 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, sparmaintainer@unisys.com, jes.sorensen@gmail.com The data field was being defined as a character array and then casted into a visor_controlvm_parameters_header structure. This patch converts it to just point to the visor_controlvm_parameters_header structure. The data following the header is still behind the header_info. Reported-by: Greg Kroah-Hartman Signed-off-by: David Kershner Reviewed-by: Tim Sell --- drivers/staging/unisys/visorbus/visorchipset.c | 23 +++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 3a8357e..d27e0e8 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -53,7 +53,7 @@ struct parser_context { u8 *curr; unsigned long bytes_remaining; bool byte_stream; - char data[0]; + struct visor_controlvm_parameters_header data; }; /* VMCALL_CONTROLVM_ADDR: Used by all guests, not just IO. */ @@ -299,10 +299,7 @@ static DEVICE_ATTR_RW(remaining_steps); static const guid_t *parser_id_get(struct parser_context *ctx) { - struct visor_controlvm_parameters_header *phdr = NULL; - - phdr = (struct visor_controlvm_parameters_header *)(ctx->data); - return &phdr->id; + return &ctx->data.id; } static void parser_done(struct parser_context *ctx) @@ -348,12 +345,12 @@ static void *parser_name_get(struct parser_context *ctx) { struct visor_controlvm_parameters_header *phdr = NULL; - phdr = (struct visor_controlvm_parameters_header *)(ctx->data); + phdr = &ctx->data; if (phdr->name_offset + phdr->name_length > ctx->param_bytes) return NULL; - ctx->curr = ctx->data + phdr->name_offset; + ctx->curr = (char *)&phdr + phdr->name_offset; ctx->bytes_remaining = phdr->name_length; return parser_string_get(ctx); } @@ -1455,17 +1452,15 @@ void visorbus_device_changestate_response(struct visor_device *dev_info, static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, bool *retry) { - int allocbytes = sizeof(struct parser_context) + bytes; + int allocbytes; struct parser_context *ctx; void *mapping; *retry = false; - /* - * alloc an 0 extra byte to ensure payload is - * '\0'-terminated - */ - allocbytes++; + /* alloc an extra byte to ensure payload is \0 terminated */ + allocbytes = bytes + 1 + (sizeof(struct parser_context) - + sizeof(struct visor_controlvm_parameters_header)); if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) > MAX_CONTROLVM_PAYLOAD_BYTES) { *retry = true; @@ -1482,7 +1477,7 @@ static struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, mapping = memremap(addr, bytes, MEMREMAP_WB); if (!mapping) goto err_finish_ctx; - memcpy(ctx->data, mapping, bytes); + memcpy(&ctx->data, mapping, bytes); memunmap(mapping); ctx->byte_stream = true; chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes; -- git-series 0.9.1 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel