dma-trace: free buffer on error

We are leaking memory if the host sends bad messages to the firmware
since we are not freeing the buffer.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This commit is contained in:
Curtis Malainey 2020-10-27 19:49:47 -07:00 committed by Liam Girdwood
parent 85986e1f4f
commit 9b5ba31938
1 changed files with 16 additions and 0 deletions

View File

@ -215,6 +215,19 @@ static int dma_trace_buffer_init(struct dma_trace_data *d)
return 0;
}
static void dma_trace_buffer_free(struct dma_trace_data *d)
{
struct dma_trace_buf *buffer = &d->dmatb;
unsigned int flags;
spin_lock_irq(&d->lock, flags);
rfree(buffer->addr);
memset(buffer, 0, sizeof(*buffer));
spin_unlock_irq(&d->lock, flags);
}
#if CONFIG_DMA_GW
static int dma_trace_start(struct dma_trace_data *d)
@ -349,6 +362,9 @@ int dma_trace_enable(struct dma_trace_data *d)
schedule_task(&d->dmat_work, DMA_TRACE_PERIOD, DMA_TRACE_PERIOD);
out:
if (err < 0)
dma_trace_buffer_free(d);
platform_shared_commit(d, sizeof(*d));
return err;