aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/asihpi
diff options
context:
space:
mode:
authorEliot Blennerhassett <eliot@blennerhassett.gen.nz>2014-11-19 22:22:57 -0500
committerTakashi Iwai <tiwai@suse.de>2014-11-22 16:34:06 -0500
commit51e6f47dd2e3463dac6f37128fd7b7cb40c500de (patch)
treebd73a95f036a7b14f4b8f8e61e69a044bcd6ac14 /sound/pci/asihpi
parentdc612838eac746b11bb4e5d923dafeea0ba7e81b (diff)
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>
Diffstat (limited to 'sound/pci/asihpi')
-rw-r--r--sound/pci/asihpi/hpimsginit.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/sound/pci/asihpi/hpimsginit.c b/sound/pci/asihpi/hpimsginit.c
index 032d563e3708..7eb617175fde 100644
--- a/sound/pci/asihpi/hpimsginit.c
+++ b/sound/pci/asihpi/hpimsginit.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 2
3 AudioScience HPI driver 3 AudioScience HPI driver
4 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com> 4 Copyright (C) 1997-2014 AudioScience Inc. <support@audioscience.com>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of version 2 of the GNU General Public License as 7 it under the terms of version 2 of the GNU General Public License as
@@ -37,11 +37,15 @@ static u16 gwSSX2_bypass;
37static void hpi_init_message(struct hpi_message *phm, u16 object, 37static void hpi_init_message(struct hpi_message *phm, u16 object,
38 u16 function) 38 u16 function)
39{ 39{
40 memset(phm, 0, sizeof(*phm)); 40 u16 size;
41
41 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) 42 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
42 phm->size = msg_size[object]; 43 size = msg_size[object];
43 else 44 else
44 phm->size = sizeof(*phm); 45 size = sizeof(*phm);
46
47 memset(phm, 0, size);
48 phm->size = size;
45 49
46 if (gwSSX2_bypass) 50 if (gwSSX2_bypass)
47 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE; 51 phm->type = HPI_TYPE_SSX2BYPASS_MESSAGE;
@@ -60,12 +64,16 @@ static void hpi_init_message(struct hpi_message *phm, u16 object,
60void hpi_init_response(struct hpi_response *phr, u16 object, u16 function, 64void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
61 u16 error) 65 u16 error)
62{ 66{
63 memset(phr, 0, sizeof(*phr)); 67 u16 size;
64 phr->type = HPI_TYPE_RESPONSE; 68
65 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) 69 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX))
66 phr->size = res_size[object]; 70 size = res_size[object];
67 else 71 else
68 phr->size = sizeof(*phr); 72 size = sizeof(*phr);
73
74 memset(phr, 0, sizeof(*phr));
75 phr->size = size;
76 phr->type = HPI_TYPE_RESPONSE;
69 phr->object = object; 77 phr->object = object;
70 phr->function = function; 78 phr->function = function;
71 phr->error = error; 79 phr->error = error;
@@ -86,7 +94,7 @@ void hpi_init_message_response(struct hpi_message *phm,
86static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size, 94static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
87 u16 object, u16 function) 95 u16 object, u16 function)
88{ 96{
89 memset(phm, 0, sizeof(*phm)); 97 memset(phm, 0, size);
90 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) { 98 if ((object > 0) && (object <= HPI_OBJ_MAXINDEX)) {
91 phm->size = size; 99 phm->size = size;
92 phm->type = HPI_TYPE_REQUEST; 100 phm->type = HPI_TYPE_REQUEST;
@@ -100,7 +108,9 @@ static void hpi_init_messageV1(struct hpi_message_header *phm, u16 size,
100void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, 108void hpi_init_responseV1(struct hpi_response_header *phr, u16 size,
101 u16 object, u16 function) 109 u16 object, u16 function)
102{ 110{
103 memset(phr, 0, sizeof(*phr)); 111 (void)object;
112 (void)function;
113 memset(phr, 0, size);
104 phr->size = size; 114 phr->size = size;
105 phr->version = 1; 115 phr->version = 1;
106 phr->type = HPI_TYPE_RESPONSE; 116 phr->type = HPI_TYPE_RESPONSE;