Skip to content

Commit 2d72fd2

Browse files
mh12gx2825lrgirdwo
authored andcommitted
sof: audio: free memory before returning in error
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 <mh12gx2825@gmail.com>
1 parent f7e6a03 commit 2d72fd2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/audio/kpb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,19 @@ static struct comp_dev *kpb_new(const struct comp_driver *drv,
154154

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

160161
if (kpb->config.channels > KPB_MAX_SUPPORTED_CHANNELS) {
161162
comp_err(dev, "kpb_new(): no of channels exceeded the limit");
163+
rfree(dev);
162164
return NULL;
163165
}
164166

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

0 commit comments

Comments
 (0)