diff options
| -rw-r--r-- | sound/soc/intel/common/sst-ipc.c | 29 | ||||
| -rw-r--r-- | sound/soc/intel/common/sst-ipc.h | 4 |
2 files changed, 30 insertions, 3 deletions
diff --git a/sound/soc/intel/common/sst-ipc.c b/sound/soc/intel/common/sst-ipc.c index a7699f35a8d2..a12c7bb08d3b 100644 --- a/sound/soc/intel/common/sst-ipc.c +++ b/sound/soc/intel/common/sst-ipc.c | |||
| @@ -129,11 +129,31 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc) | |||
| 129 | return -ENOMEM; | 129 | return -ENOMEM; |
| 130 | 130 | ||
| 131 | for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) { | 131 | for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) { |
| 132 | ipc->msg[i].tx_data = kzalloc(ipc->tx_data_max_size, GFP_KERNEL); | ||
| 133 | if (ipc->msg[i].tx_data == NULL) | ||
| 134 | goto free_mem; | ||
| 135 | |||
| 136 | ipc->msg[i].rx_data = kzalloc(ipc->rx_data_max_size, GFP_KERNEL); | ||
| 137 | if (ipc->msg[i].rx_data == NULL) { | ||
| 138 | kfree(ipc->msg[i].tx_data); | ||
| 139 | goto free_mem; | ||
| 140 | } | ||
| 141 | |||
| 132 | init_waitqueue_head(&ipc->msg[i].waitq); | 142 | init_waitqueue_head(&ipc->msg[i].waitq); |
| 133 | list_add(&ipc->msg[i].list, &ipc->empty_list); | 143 | list_add(&ipc->msg[i].list, &ipc->empty_list); |
| 134 | } | 144 | } |
| 135 | 145 | ||
| 136 | return 0; | 146 | return 0; |
| 147 | |||
| 148 | free_mem: | ||
| 149 | while (i > 0) { | ||
| 150 | kfree(ipc->msg[i-1].tx_data); | ||
| 151 | kfree(ipc->msg[i-1].rx_data); | ||
| 152 | --i; | ||
| 153 | } | ||
| 154 | kfree(ipc->msg); | ||
| 155 | |||
| 156 | return -ENOMEM; | ||
| 137 | } | 157 | } |
| 138 | 158 | ||
| 139 | static void ipc_tx_msgs(struct kthread_work *work) | 159 | static void ipc_tx_msgs(struct kthread_work *work) |
| @@ -279,11 +299,18 @@ EXPORT_SYMBOL_GPL(sst_ipc_init); | |||
| 279 | 299 | ||
| 280 | void sst_ipc_fini(struct sst_generic_ipc *ipc) | 300 | void sst_ipc_fini(struct sst_generic_ipc *ipc) |
| 281 | { | 301 | { |
| 302 | int i; | ||
| 303 | |||
| 282 | if (ipc->tx_thread) | 304 | if (ipc->tx_thread) |
| 283 | kthread_stop(ipc->tx_thread); | 305 | kthread_stop(ipc->tx_thread); |
| 284 | 306 | ||
| 285 | if (ipc->msg) | 307 | if (ipc->msg) { |
| 308 | for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) { | ||
| 309 | kfree(ipc->msg[i].tx_data); | ||
| 310 | kfree(ipc->msg[i].rx_data); | ||
| 311 | } | ||
| 286 | kfree(ipc->msg); | 312 | kfree(ipc->msg); |
| 313 | } | ||
| 287 | } | 314 | } |
| 288 | EXPORT_SYMBOL_GPL(sst_ipc_fini); | 315 | EXPORT_SYMBOL_GPL(sst_ipc_fini); |
| 289 | 316 | ||
diff --git a/sound/soc/intel/common/sst-ipc.h b/sound/soc/intel/common/sst-ipc.h index 7139afd2547f..ceb7e468a3fa 100644 --- a/sound/soc/intel/common/sst-ipc.h +++ b/sound/soc/intel/common/sst-ipc.h | |||
| @@ -32,9 +32,9 @@ struct ipc_message { | |||
| 32 | u64 header; | 32 | u64 header; |
| 33 | 33 | ||
| 34 | /* direction wrt host CPU */ | 34 | /* direction wrt host CPU */ |
| 35 | char tx_data[IPC_MAX_MAILBOX_BYTES]; | 35 | char *tx_data; |
| 36 | size_t tx_size; | 36 | size_t tx_size; |
| 37 | char rx_data[IPC_MAX_MAILBOX_BYTES]; | 37 | char *rx_data; |
| 38 | size_t rx_size; | 38 | size_t rx_size; |
| 39 | 39 | ||
| 40 | wait_queue_head_t waitq; | 40 | wait_queue_head_t waitq; |
