Skip to content

Conversation

@kv2019i
Copy link
Collaborator

@kv2019i kv2019i commented Dec 21, 2022

marc-hb and others added 8 commits December 21, 2022 15:09
Finish the job that commit 5b29dae ("logger: Create global
convert_config variable to avoid spaghetti code.") started but did not
finish, leaving behind a supposedly "global" variable that is actually a
confusing global pointer to a struct local to the main() function.

This confuses some static analyzer complaining that stack values are
being returned, see thesofproject#6858 and thesofproject#6738. This is a false positive
because the main()'s stack lifespan is the same as a global but let's
simplify things anyway.

Also stop using 'extern' in .c files, use a proper .h file instead.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
(cherry picked from commit 327a26b)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Finish the job that commit 5b29dae ("logger: Create global
convert_config variable to avoid spaghetti code.") started but did not
complete, leaving a confusing mix of globals and locals.

This confuses some static analyzer complaining that stack values are
being returned, see thesofproject#6858 and thesofproject#6738. This is a false positive because
convert's() stack lifespan is practically the same as a global but let's
simplify things anyway.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
(cherry picked from commit 2dfaee6)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fix a case of a possible array overflow, detected by static code
analysis.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
(cherry picked from commit 0b295eb)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Make sure there's at least one channel in the volume configuration.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
(cherry picked from commit 24062b4)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Check source and sink channels to avoid accessing beyond array
boundaries.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
(cherry picked from commit d5e9794)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
localtime() can return NULL in error cases. Check the return value
before dereferencing it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
(cherry picked from commit 84b2dd2)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
With IPC4 only two 32-bit values are copied from the host in the
common part, anything beyond that must be copied separately. Those
two values are stored in a global msg_data.msg_in object. Therefore
always when reading from it only up to 8 bytes should be read. In
most cases it is also the case, because the target object has the
same size, but in case of SOF_IPC4_MOD_INIT_INSTANCE this isn't the
case, there special care must be taken.

Also remove a redundant NULL check where NULL cannot appear.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
(cherry picked from commit 96686cf)
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Due to allocation failures, or invalid content in dictionary,
"params" entries in "struct proc_ldc_entry" may be NULL.

In print_entry_params(), the NULL entries may be passed
as arguments to fprintf(). While e.g. glibc handles these without
error, this is not guaranteed behaviour and may result in segfault
on some platforms.

Fix the issue by aborting program if allocation fails and
explicitly handling the cases when asprintf_entry_text returns
NULL.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
(cherry picked from commit 1a7a36a)
@kv2019i kv2019i requested review from lgirdwood and mwasko December 21, 2022 13:28
int ret;

memcpy_s(&cdma, sizeof(cdma), ipc4, sizeof(cdma));
memcpy_s(&cdma, sizeof(cdma), ipc4, sizeof(*ipc4));
Copy link
Contributor

@ujfalusi ujfalusi Dec 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just obfuscation of what we do...

cdma.primary.dat = ipc4->primary.dat;
cdma.extension.dat = ipc4->extension.dat;

is done here or the ipc4 point to be re-casted to chain dma struct:

struct ipc4_chain_dma *cdma = (struct ipc4_chain_dma *) ipc4;

it could be safer to have a local copy, but I don't think it matter, using the same memory is fine here.

@lgirdwood lgirdwood merged commit 482d60f into thesofproject:stable-v2.4 Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants