summaryrefslogtreecommitdiffstats
path: root/sound/x86
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-02-15 21:42:20 +0100
committerTakashi Iwai <tiwai@suse.de>2017-02-16 09:22:42 +0100
commit18353192b8f696a27420e2e8f39804c2075f26fb (patch)
tree249ee4bd572f191ae81c9853318a0782bd0d0235 /sound/x86
parentALSA: x86: Use snd_pcm_stop_xrun() for connection / disconnection paths (diff)
downloadlinux-18353192b8f696a27420e2e8f39804c2075f26fb.tar.xz
linux-18353192b8f696a27420e2e8f39804c2075f26fb.zip
ALSA: x86: Fix memory leak in had_build_channel_allocation_map()
The previously allocated chmap has to be released before setting the new one. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/x86')
-rw-r--r--sound/x86/intel_hdmi_audio.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index a7343f2d2730..5f2445389716 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -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]);
@@ -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);
- }
}
/*