ALSA: asihpi: used parts of message/response are zeroed before use

Signed-off-by: Eliot Blennerhassett <eliot@blennerhassett.gen.nz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Eliot Blennerhassett 2014-11-20 16:22:57 +13:00 committed by Takashi Iwai
parent dc612838ea
commit 51e6f47dd2
1 changed files with 20 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************** /******************************************************************************
AudioScience HPI driver AudioScience HPI driver
Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com> Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as it under the terms of version 2 of the GNU General Public License as
@ -37,11 +37,15 @@ static u16 gwSSX2_bypass;
static void hpi_init_message(struct hpi_message *phm, u16 object, static void hpi_init_message(struct hpi_message *phm, u16 object,
u16 function) u16 function)
{ {
memset(phm, 0, sizeof(*phm)); u16 size;
if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
phm->size = msg_size[object]; size = msg_size[object];
else else
phm->size = sizeof(*phm); size = sizeof(*phm);
memset(phm, 0, size);
phm->size = size;
if (gwSSX2_bypass) if (gwSSX2_bypass)
phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE; phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
@ -60,12 +64,16 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
u16 error) u16 error)
{ {
memset(phr, 0, sizeof(*phr)); u16 size;
phr->type = HPI_TYPE_RESPONSE;
if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
phr->size = res_size[object]; size = res_size[object];
else else
phr->size = sizeof(*phr); size = sizeof(*phr);
memset(phr, 0, sizeof(*phr));
phr->size = size;
phr->type = HPI_TYPE_RESPONSE;
phr->object = object; phr->object = object;
phr->function = function; phr->function = function;
phr->error = error; phr->error = error;
@ -86,7 +94,7 @@ void hpi_init_message_response(struct hpi_message *phm,
static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size, static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
u16 object, u16 function) u16 object, u16 function)
{ {
memset(phm, 0, sizeof(*phm)); memset(phm, 0, size);
if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) { if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
phm->size = size; phm->size = size;
phm->type = HPI_TYPE_REQUEST; phm->type = HPI_TYPE_REQUEST;
@ -100,7 +108,9 @@ static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, void hpi_init_responseV1(struct hpi_response_header *phr, u16 size,
u16 object, u16 function) u16 object, u16 function)
{ {
memset(phr, 0, sizeof(*phr)); (void)object;
(void)function;
memset(phr, 0, size);
phr->size = size; phr->size = size;
phr->version = 1; phr->version = 1;
phr->type = HPI_TYPE_RESPONSE; phr->type = HPI_TYPE_RESPONSE;