Skip to content

Commit c6a502c

Browse files
khoroshilovdavem330
authored andcommitted
mISDN: Fix memory leak in dsp_pipeline_build()
dsp_pipeline_build() allocates dup pointer by kstrdup(cfg), but then it updates dup variable by strsep(&dup, "|"). As a result when it calls kfree(dup), the dup variable contains NULL. Found by Linux Driver Verification project (linuxtesting.org) with SVACE. Signed-off-by: Alexey Khoroshilov <[email protected]> Fixes: 960366c ("Add mISDN DSP") Signed-off-by: David S. Miller <[email protected]>
1 parent a502a8f commit c6a502c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/isdn/mISDN/dsp_pipeline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
192192
int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
193193
{
194194
int found = 0;
195-
char *dup, *tok, *name, *args;
195+
char *dup, *next, *tok, *name, *args;
196196
struct dsp_element_entry *entry, *n;
197197
struct dsp_pipeline_entry *pipeline_entry;
198198
struct mISDN_dsp_element *elem;
@@ -203,10 +203,10 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
203203
if (!list_empty(&pipeline->list))
204204
_dsp_pipeline_destroy(pipeline);
205205

206-
dup = kstrdup(cfg, GFP_ATOMIC);
206+
dup = next = kstrdup(cfg, GFP_ATOMIC);
207207
if (!dup)
208208
return 0;
209-
while ((tok = strsep(&dup, "|"))) {
209+
while ((tok = strsep(&next, "|"))) {
210210
if (!strlen(tok))
211211
continue;
212212
name = strsep(&tok, "(");

0 commit comments

Comments
 (0)