Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18353192 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

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: default avatarTakashi Iwai <tiwai@suse.de>
parent 5def9019
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -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;

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

	chmap = kzalloc(sizeof(*chmap), GFP_KERNEL);
	if (!chmap)
		return;
	}

	dev_dbg(intelhaddata->dev, "eld speaker = %x\n",
		intelhaddata->eld[DRM_ELD_SPEAKER]);
@@ -493,11 +494,9 @@ 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);
}
}

/*
 * ALSA API channel-map control callbacks