Skip to content

Commit

Permalink
sof: audio: free memory before returning in error
Browse files Browse the repository at this point in the history
Memory allocated for new KPB component should be released before
returning NULL in when one of sampling width or number of channels or
sampling frequency are set to unexpected values.

Signed-off-by: Deepak R Varma <[email protected]>
  • Loading branch information
mh12gx2825 authored and lrgirdwo committed Apr 21, 2020
1 parent f7e6a03 commit 2d72fd2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,19 @@ static struct comp_dev *kpb_new(const struct comp_driver *drv,

if (!kpb_is_sample_width_supported(kpb->config.sampling_width)) {
comp_err(dev, "kpb_new(): requested sampling width not supported");
rfree(dev);
return NULL;
}

if (kpb->config.channels > KPB_MAX_SUPPORTED_CHANNELS) {
comp_err(dev, "kpb_new(): no of channels exceeded the limit");
rfree(dev);
return NULL;
}

if (kpb->config.sampling_freq != KPB_SAMPLNG_FREQUENCY) {
comp_err(dev, "kpb_new(): requested sampling frequency not supported");
rfree(dev);
return NULL;
}

Expand Down

0 comments on commit 2d72fd2

Please sign in to comment.