mirror of https://github.com/thesofproject/sof.git
testbench: add null pointer check for function argument
tb_pipeline_params() function takes an argument called ipc_pipe, which is a pointer and is derefernced in the function to access a member of structure that pointer is pointing to. If this pointer is NULL, this leads to Segmentation fault. A null pointer check is added before the argument is dereferenced. Signed-off-by: Mohana Datta Yelugoti <ymdatta.work@gmail.com>
This commit is contained in:
parent
41e62eb4ba
commit
9f1106d8a5
|
@ -99,9 +99,16 @@ int tb_pipeline_params(struct ipc *ipc, struct sof_ipc_pipe_new *ipc_pipe,
|
|||
struct sof_ipc_pcm_params params;
|
||||
char message[DEBUG_MSG_LEN];
|
||||
int fs_period;
|
||||
int period = ipc_pipe->period;
|
||||
int period;
|
||||
int ret = 0;
|
||||
|
||||
if (!ipc_pipe) {
|
||||
fprintf(stderr, "error: ipc_pipe NULL\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
period = ipc_pipe->period;
|
||||
|
||||
/* Compute period from sample rates */
|
||||
fs_period = (int)(0.9999 + tp->fs_in * period / 1e6);
|
||||
sprintf(message, "period sample count %d\n", fs_period);
|
||||
|
|
Loading…
Reference in New Issue