All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH alsa-lib 1/8] topology: decode: fix channel map memory allocation
@ 2020-06-25 11:03 Piotr Maziarz
  2020-06-25 11:03 ` [PATCH alsa-lib 2/8] topology: decode: Fix adding texts field to enum control Piotr Maziarz
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Piotr Maziarz @ 2020-06-25 11:03 UTC (permalink / raw)
  To: alsa-devel; +Cc: cezary.rojewski, amadeuszx.slawinski

Without proper memory allocation behaviour was undefined.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com>
---
 src/topology/ctl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/topology/ctl.c b/src/topology/ctl.c
index 90241b6..c8c7e94 100644
--- a/src/topology/ctl.c
+++ b/src/topology/ctl.c
@@ -1330,7 +1330,6 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg,
 			      void *bin, size_t size)
 {
 	struct snd_soc_tplg_enum_control *ec = bin;
-	struct snd_tplg_channel_map_template cmt;
 	int i;
 
 	if (size < sizeof(*ec)) {
@@ -1375,11 +1374,11 @@ int tplg_decode_control_enum1(snd_tplg_t *tplg,
 		}
 	}
 
-	et->map = &cmt;
-	memset(&cmt, 0, sizeof(cmt));
-	cmt.num_channels = ec->num_channels;
-	for (i = 0; i < cmt.num_channels; i++) {
-		struct snd_tplg_channel_elem *channel = &cmt.channel[i];
+	et->map = tplg_calloc(heap, sizeof(struct snd_tplg_channel_map_template));
+	et->map->num_channels = ec->num_channels;
+	for (i = 0; i < et->map->num_channels; i++) {
+		struct snd_tplg_channel_elem *channel = &et->map->channel[i];
+
 		tplg_log(tplg, 'D', pos + ((void *)&ec->channel[i] - (void *)ec),
 			 "enum: channel size %d", ec->channel[i].size);
 		channel->reg = ec->channel[i].reg;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-07-02 15:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-25 11:03 [PATCH alsa-lib 1/8] topology: decode: fix channel map memory allocation Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 2/8] topology: decode: Fix adding texts field to enum control Piotr Maziarz
2020-06-25 14:24   ` Pierre-Louis Bossart
2020-06-25 11:03 ` [PATCH alsa-lib 3/8] topology: decode: Fix printing texts section Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 4/8] topology: decode: Change declaration of enum decoding function Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 5/8] topology: decode: Fix decoding PCM formats and rates Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 6/8] topology: decode: Print sig_bits field in PCM capabilities section Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 7/8] topology: decode: Add DAI name printing Piotr Maziarz
2020-06-25 11:03 ` [PATCH alsa-lib 8/8] topology: Make buffer for saving dynamic size Piotr Maziarz
2020-06-25 14:31   ` Pierre-Louis Bossart
2020-07-02 15:04     ` Piotr Maziarz
2020-06-25 14:16 ` [PATCH alsa-lib 1/8] topology: decode: fix channel map memory allocation Pierre-Louis Bossart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.