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>
This commit is contained in:
Takashi Iwai 2017-02-15 21:42:20 +01:00
Родитель 5def90196b
Коммит 18353192b8
1 изменённых файлов: 5 добавлений и 6 удалений

Просмотреть файл

@ -444,11 +444,12 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
u8 eld_high, eld_high_mask = 0xF0; u8 eld_high, eld_high_mask = 0xF0;
u8 high_msb; u8 high_msb;
kfree(intelhaddata->chmap->chmap);
intelhaddata->chmap->chmap = NULL;
chmap = kzalloc(sizeof(*chmap), GFP_KERNEL); chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
if (!chmap) { if (!chmap)
intelhaddata->chmap->chmap = NULL;
return; return;
}
dev_dbg(intelhaddata->dev, "eld speaker = %x\n", dev_dbg(intelhaddata->dev, "eld speaker = %x\n",
intelhaddata->eld[DRM_ELD_SPEAKER]); intelhaddata->eld[DRM_ELD_SPEAKER]);
@ -493,10 +494,8 @@ static void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata)
break; break;
} }
} }
if (i >= ARRAY_SIZE(channel_allocations)) { if (i >= ARRAY_SIZE(channel_allocations))
intelhaddata->chmap->chmap = NULL;
kfree(chmap); kfree(chmap);
}
} }
/* /*