Skip to content

Commit

Permalink
ALSA: x86: Fix memory leak in had_build_channel_allocation_map()
Browse files Browse the repository at this point in the history
The previously allocated chmap has to be released before setting the
new one.

Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Feb 16, 2017
1 parent 5def901 commit 1835319
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sound/x86/intel_hdmi_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,12 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
u8 eld_high, eld_high_mask = 0xF0;
u8 high_msb;

kfree(intelhaddata->chmap->chmap);
intelhaddata->chmap->chmap = NULL;

chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
if (!chmap) {
intelhaddata->chmap->chmap = NULL;
if (!chmap)
return;
}

dev_dbg(intelhaddata->dev, "eld speaker = %x\n",
intelhaddata->eld[DRM_ELD_SPEAKER]);
Expand Down Expand Up @@ -493,10 +494,8 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
break;
}
}
if (i >= ARRAY_SIZE(channel_allocations)) {
intelhaddata->chmap->chmap = NULL;
if (i >= ARRAY_SIZE(channel_allocations))
kfree(chmap);
}
}

/*
Expand Down

0 comments on commit 1835319

Please sign in to comment.