trace: don't copy uninitialized field from dma_sw_elem parameter

Coverity issue: 254842 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier
computations.

In parse_page_descriptors: Use of an uninitialized variable (CWE-457)
The elem.src variable is not initialized, but in
dma_trace_host_buffer() the code reads this initialized value.

Break

	*e = *elem;

in
	e->dest = elem->dest;
	e->size = elem->size;

to only access relevant fields.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
This commit is contained in:
Pierre-Louis Bossart 2018-01-19 16:33:14 -06:00 committed by Liam Girdwood
parent 8440ec3f18
commit 97e4232f7f
1 changed files with 4 additions and 1 deletions

View File

@ -185,7 +185,10 @@ int dma_trace_host_buffer(struct dma_trace_data *d, struct dma_sg_elem *elem,
if (e == NULL) if (e == NULL)
return -ENOMEM; return -ENOMEM;
*e = *elem; /* copy fields - excluding possibly non-initialized elem->src */
e->dest = elem->dest;
e->size = elem->size;
d->host_size = host_size; d->host_size = host_size;
list_item_append(&e->list, &d->config.elem_list); list_item_append(&e->list, &d->config.elem_list);