All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver
@ 2017-11-07 10:46 Guneshwor Singh
  2017-11-07 10:46 ` [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format Guneshwor Singh
                   ` (11 more replies)
  0 siblings, 12 replies; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Liam Girdwood, Vinod Koul, Guneshwor Singh, Patches Audio

This series include couple of bug fixes which include memory leak fixes, null
pointer dereference fixes, fixes for errors generated by static checker, updown
mixer module ipc format fix and use module uuid instead of module id which is
required for module pins.

Guneshwor Singh (2):
  ASoC: Intel: Skylake: Fix updown mixer module format
  ASoC: Intel: Skylake: Add channel map in updown mixer module IPC

Pankaj Bharadiya (3):
  ASoC: Intel: Skylake: Fix potential NULL pointer dereference
  ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case
  ASoC: Intel: Skylake: Check for NHLT ACPI header signature

Sriram Periyasamy (2):
  ASoC: Intel: Skylake: Optimize UUID handling to fill pin info
  ASoC: Intel: Skylake: Add dynamic module id support

Subhransu S. Prusty (4):
  ASoC: Intel: Skylake: Remove second shim read in register_poll
  ASoC: hdac_hdmi: Fix static checker warning for sprintf usage
  ASoC: hdac_hdmi: Fix possible NULL pointer dereference
  ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure

 sound/soc/codecs/hdac_hdmi.c            | 51 ++++++++++++++++++++++----
 sound/soc/intel/common/sst-dsp.c        |  4 +-
 sound/soc/intel/skylake/skl-messages.c  |  9 +----
 sound/soc/intel/skylake/skl-nhlt.c      |  9 +++++
 sound/soc/intel/skylake/skl-pcm.c       |  3 +-
 sound/soc/intel/skylake/skl-sst-utils.c | 15 ++++++--
 sound/soc/intel/skylake/skl-topology.c  | 65 +++++++++++++++++++++------------
 sound/soc/intel/skylake/skl-topology.h  |  3 +-
 8 files changed, 112 insertions(+), 47 deletions(-)

-- 
2.14.2

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

* [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix updown mixer module format" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 02/11] ASoC: Intel: Skylake: Add channel map in updown mixer module IPC Guneshwor Singh
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Liam Girdwood, Vinod Koul, Guneshwor Singh, Patches Audio

DSP expects length of the coefficient for updown mixer module to be 8.
So fix the max coefficient length and since we are using default values
for coefficient select which is zero, we need not explicitly initialize
it.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-messages.c | 8 --------
 sound/soc/intel/skylake/skl-topology.h | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index f637829833e6..49e6a4d7adfc 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -707,18 +707,10 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
 	struct skl_module *module = mconfig->module;
 	struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
 	struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
-	int i = 0;
 
 	skl_set_base_module_format(ctx,	mconfig,
 		(struct skl_base_cfg *)mixer_mconfig);
 	mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
-
-	/* Select F/W default coefficient */
-	mixer_mconfig->coeff_sel = 0x0;
-
-	/* User coeff, don't care since we are selecting F/W defaults */
-	for (i = 0; i < UP_DOWN_MIXER_MAX_COEFF; i++)
-		mixer_mconfig->coeff[i] = 0xDEADBEEF;
 }
 
 /*
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index d116599bfdd7..28316cb4f36f 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -34,7 +34,7 @@
 #define MAX_FIXED_DMIC_PARAMS_SIZE 727
 
 /* Maximum number of coefficients up down mixer module */
-#define UP_DOWN_MIXER_MAX_COEFF		6
+#define UP_DOWN_MIXER_MAX_COEFF		8
 
 #define MODULE_MAX_IN_PINS	8
 #define MODULE_MAX_OUT_PINS	8
-- 
2.14.2

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

* [PATCH 02/11] ASoC: Intel: Skylake: Add channel map in updown mixer module IPC
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
  2017-11-07 10:46 ` [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Add channel map in updown mixer module IPC" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 03/11] ASoC: Intel: Skylake: Fix potential NULL pointer dereference Guneshwor Singh
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Liam Girdwood, Vinod Koul, Guneshwor Singh, Patches Audio

DSP expects channel map to be sent in the IPC for updown mixer module.
So add ch_map info in updown mixer module config.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-messages.c | 1 +
 sound/soc/intel/skylake/skl-topology.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index 49e6a4d7adfc..61b5bfa79d13 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -711,6 +711,7 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
 	skl_set_base_module_format(ctx,	mconfig,
 		(struct skl_base_cfg *)mixer_mconfig);
 	mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
+	mixer_mconfig->ch_map = fmt->ch_map;
 }
 
 /*
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index 28316cb4f36f..b6496513fe55 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -161,6 +161,7 @@ struct skl_up_down_mixer_cfg {
 	u32 coeff_sel;
 	/* Pass the user coeff in this array */
 	s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
+	u32 ch_map;
 } __packed;
 
 struct skl_algo_cfg {
-- 
2.14.2

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

* [PATCH 03/11] ASoC: Intel: Skylake: Fix potential NULL pointer dereference
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
  2017-11-07 10:46 ` [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format Guneshwor Singh
  2017-11-07 10:46 ` [PATCH 02/11] ASoC: Intel: Skylake: Add channel map in updown mixer module IPC Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix potential NULL pointer dereference" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 04/11] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case Guneshwor Singh
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Pankaj Bharadiya, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Vinod Koul

From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>

Pointer 'mconfig' returned from call to skl_tplg_fe_get_cpr_module() can
be NULL. So check for the valid pointer before dereferencing.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-pcm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 4380e40c6af0..1dd97479e0c0 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -355,7 +355,8 @@ static void skl_pcm_close(struct snd_pcm_substream *substream,
 	}
 
 	mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
-	skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
+	if (mconfig)
+		skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
 
 	kfree(dma_params);
 }
-- 
2.14.2

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

* [PATCH 04/11] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (2 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 03/11] ASoC: Intel: Skylake: Fix potential NULL pointer dereference Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 05/11] ASoC: Intel: Skylake: Remove second shim read in register_poll Guneshwor Singh
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Pankaj Bharadiya, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Vinod Koul

From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>

In the loop that adds the uuid_module to the uuid_list list, allocated
memory is not properly freed in the error path free uuid_list whenever
any of the memory allocation in the loop fails to avoid memory leak.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-sst-utils.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
index 369ef7ce981c..8ff89280d9fd 100644
--- a/sound/soc/intel/skylake/skl-sst-utils.c
+++ b/sound/soc/intel/skylake/skl-sst-utils.c
@@ -251,6 +251,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 	struct uuid_module *module;
 	struct firmware stripped_fw;
 	unsigned int safe_file;
+	int ret = 0;
 
 	/* Get the FW pointer to derive ADSP header */
 	stripped_fw.data = fw->data;
@@ -299,8 +300,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 
 	for (i = 0; i < num_entry; i++, mod_entry++) {
 		module = kzalloc(sizeof(*module), GFP_KERNEL);
-		if (!module)
-			return -ENOMEM;
+		if (!module) {
+			ret = -ENOMEM;
+			goto free_uuid_list;
+		}
 
 		uuid_bin = (uuid_le *)mod_entry->uuid.id;
 		memcpy(&module->uuid, uuid_bin, sizeof(module->uuid));
@@ -311,8 +314,8 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 		size = sizeof(int) * mod_entry->instance_max_count;
 		module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
 		if (!module->instance_id) {
-			kfree(module);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto free_uuid_list;
 		}
 
 		list_add_tail(&module->list, &skl->uuid_list);
@@ -323,6 +326,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 	}
 
 	return 0;
+
+free_uuid_list:
+	skl_freeup_uuid_list(skl);
+	return ret;
 }
 
 void skl_freeup_uuid_list(struct skl_sst *ctx)
-- 
2.14.2

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

* [PATCH 05/11] ASoC: Intel: Skylake: Remove second shim read in register_poll
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (3 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 04/11] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-12-06 17:49   ` Applied "ASoC: Intel: Skylake: Remove second shim read in register_poll" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 06/11] ASoC: Intel: Skylake: Check for NHLT ACPI header signature Guneshwor Singh
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, Liam Girdwood,
	Vinod Koul, Subhransu S. Prusty

From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>

No need to read the register again if the value read has already matched
the target during the loop. So remove the second shim read.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/common/sst-dsp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c
index 11c0805393ff..fd82f4b1d4a0 100644
--- a/sound/soc/intel/common/sst-dsp.c
+++ b/sound/soc/intel/common/sst-dsp.c
@@ -269,7 +269,7 @@ int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
 	 */
 
 	timeout = jiffies + msecs_to_jiffies(time);
-	while (((sst_dsp_shim_read_unlocked(ctx, offset) & mask) != target)
+	while ((((reg = sst_dsp_shim_read_unlocked(ctx, offset)) & mask) != target)
 		&& time_before(jiffies, timeout)) {
 		k++;
 		if (k > 10)
@@ -278,8 +278,6 @@ int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
 		usleep_range(s, 2*s);
 	}
 
-	reg = sst_dsp_shim_read_unlocked(ctx, offset);
-
 	if ((reg & mask) == target) {
 		dev_dbg(ctx->dev, "FW Poll Status: reg=%#x %s successful\n",
 					reg, operation);
-- 
2.14.2

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

* [PATCH 06/11] ASoC: Intel: Skylake: Check for NHLT ACPI header signature
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (4 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 05/11] ASoC: Intel: Skylake: Remove second shim read in register_poll Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Check for NHLT ACPI header signature" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 07/11] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info Guneshwor Singh
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Pankaj Bharadiya, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Vinod Koul

From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>

In certain buggy BIOS acpi_evaluate_dsm() may not return the correct
NHLT table, so check the NHLT table header signature before accessing
it.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-nhlt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index e7d766d56c8e..d14c50a60289 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -20,6 +20,8 @@
 #include <linux/pci.h>
 #include "skl.h"
 
+#define NHLT_ACPI_HEADER_SIG	"NHLT"
+
 /* Unique identification for getting NHLT blobs */
 static guid_t osc_guid =
 	GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
@@ -45,6 +47,13 @@ struct nhlt_acpi_table *skl_nhlt_init(struct device *dev)
 				memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
 				MEMREMAP_WB);
 		ACPI_FREE(obj);
+		if (nhlt_table && (strncmp(nhlt_table->header.signature,
+					NHLT_ACPI_HEADER_SIG,
+					strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
+			memunmap(nhlt_table);
+			dev_err(dev, "NHLT ACPI header signature incorrect\n");
+			return NULL;
+		}
 		return nhlt_table;
 	}
 
-- 
2.14.2

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

* [PATCH 07/11] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (5 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 06/11] ASoC: Intel: Skylake: Check for NHLT ACPI header signature Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Optimize UUID handling to fill pin info" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 08/11] ASoC: Intel: Skylake: Add dynamic module id support Guneshwor Singh
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Sriram Periyasamy, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Vinod Koul

From: Sriram Periyasamy <sriramx.periyasamy@intel.com>

Modify skl_tplg_get_uuid() to copy just UUID rather than only
for module UUID and skl_tplg_fill_pin() to fill the pin info
which can include UUID token also.

Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-topology.c | 46 +++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 036779fb5807..342943f6069b 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2036,21 +2036,35 @@ static int skl_tplg_add_pipe(struct device *dev,
 	return 0;
 }
 
-static int skl_tplg_fill_pin(struct device *dev, u32 tkn,
+static int skl_tplg_get_uuid(struct device *dev, u8 *guid,
+	      struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
+{
+	if (uuid_tkn->token == SKL_TKN_UUID) {
+		memcpy(guid, &uuid_tkn->uuid, 16);
+		return 0;
+	}
+
+	dev_err(dev, "Not an UUID token %d\n", uuid_tkn->token);
+
+	return -EINVAL;
+}
+
+static int skl_tplg_fill_pin(struct device *dev,
+			struct snd_soc_tplg_vendor_value_elem *tkn_elem,
 			struct skl_module_pin *m_pin,
-			int pin_index, u32 value)
+			int pin_index)
 {
-	switch (tkn) {
+	switch (tkn_elem->token) {
 	case SKL_TKN_U32_PIN_MOD_ID:
-		m_pin[pin_index].id.module_id = value;
+		m_pin[pin_index].id.module_id = tkn_elem->value;
 		break;
 
 	case SKL_TKN_U32_PIN_INST_ID:
-		m_pin[pin_index].id.instance_id = value;
+		m_pin[pin_index].id.instance_id = tkn_elem->value;
 		break;
 
 	default:
-		dev_err(dev, "%d Not a pin token\n", value);
+		dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
 		return -EINVAL;
 	}
 
@@ -2083,9 +2097,7 @@ static int skl_tplg_fill_pins_info(struct device *dev,
 		return -EINVAL;
 	}
 
-	ret = skl_tplg_fill_pin(dev, tkn_elem->token,
-			m_pin, pin_count, tkn_elem->value);
-
+	ret = skl_tplg_fill_pin(dev, tkn_elem, m_pin, pin_count);
 	if (ret < 0)
 		return ret;
 
@@ -2170,19 +2182,6 @@ static int skl_tplg_widget_fill_fmt(struct device *dev,
 	return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val);
 }
 
-static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig,
-	      struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
-{
-	if (uuid_tkn->token == SKL_TKN_UUID)
-		memcpy(&mconfig->guid, &uuid_tkn->uuid, 16);
-	else {
-		dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static void skl_tplg_fill_pin_dynamic_val(
 		struct skl_module_pin *mpin, u32 pin_count, u32 value)
 {
@@ -2565,7 +2564,8 @@ static int skl_tplg_get_tokens(struct device *dev,
 			continue;
 
 		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
-			ret = skl_tplg_get_uuid(dev, mconfig, array->uuid);
+			ret = skl_tplg_get_uuid(dev, mconfig->guid,
+					array->uuid);
 			if (ret < 0)
 				return ret;
 
-- 
2.14.2

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

* [PATCH 08/11] ASoC: Intel: Skylake: Add dynamic module id support
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (6 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 07/11] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:32   ` Applied "ASoC: Intel: Skylake: Add dynamic module id support" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 09/11] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage Guneshwor Singh
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Sriram Periyasamy, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Vinod Koul

From: Sriram Periyasamy <sriramx.periyasamy@intel.com>

Module id is a property of firmware manifest and can vary between
platforms so use the uuid instead of module id for pins.

Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/intel/skylake/skl-topology.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 342943f6069b..a072bcf209d2 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2054,6 +2054,8 @@ static int skl_tplg_fill_pin(struct device *dev,
 			struct skl_module_pin *m_pin,
 			int pin_index)
 {
+	int ret;
+
 	switch (tkn_elem->token) {
 	case SKL_TKN_U32_PIN_MOD_ID:
 		m_pin[pin_index].id.module_id = tkn_elem->value;
@@ -2063,6 +2065,14 @@ static int skl_tplg_fill_pin(struct device *dev,
 		m_pin[pin_index].id.instance_id = tkn_elem->value;
 		break;
 
+	case SKL_TKN_UUID:
+		ret = skl_tplg_get_uuid(dev, m_pin[pin_index].id.mod_uuid.b,
+			(struct snd_soc_tplg_vendor_uuid_elem *)tkn_elem);
+		if (ret < 0)
+			return ret;
+
+		break;
+
 	default:
 		dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
 		return -EINVAL;
@@ -2487,6 +2497,7 @@ static int skl_tplg_get_token(struct device *dev,
 
 	case SKL_TKN_U32_PIN_MOD_ID:
 	case SKL_TKN_U32_PIN_INST_ID:
+	case SKL_TKN_UUID:
 		ret = skl_tplg_fill_pins_info(dev,
 				mconfig, tkn_elem, dir,
 				pin_index);
@@ -2549,6 +2560,7 @@ static int skl_tplg_get_tokens(struct device *dev,
 	struct snd_soc_tplg_vendor_value_elem *tkn_elem;
 	int tkn_count = 0, ret;
 	int off = 0, tuple_size = 0;
+	bool is_module_guid = true;
 
 	if (block_size <= 0)
 		return -EINVAL;
@@ -2564,8 +2576,15 @@ static int skl_tplg_get_tokens(struct device *dev,
 			continue;
 
 		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
-			ret = skl_tplg_get_uuid(dev, mconfig->guid,
-					array->uuid);
+			if (is_module_guid) {
+				ret = skl_tplg_get_uuid(dev, mconfig->guid,
+							array->uuid);
+				is_module_guid = false;
+			} else {
+				ret = skl_tplg_get_token(dev, array->value, skl,
+							 mconfig);
+			}
+
 			if (ret < 0)
 				return ret;
 
-- 
2.14.2

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

* [PATCH 09/11] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (7 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 08/11] ASoC: Intel: Skylake: Add dynamic module id support Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix static checker warning for sprintf usage" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 10/11] ASoC: hdac_hdmi: Fix possible NULL pointer dereference Guneshwor Singh
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, Liam Girdwood,
	Vinod Koul, Subhransu S. Prusty

From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>

Use snprintf instead of sprintf to shut the warning.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index e824d47cc22b..6f3ff15c0962 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -942,7 +942,8 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
 	if (!se)
 		return -ENOMEM;
 
-	sprintf(kc_name, "Pin %d port %d Input", pin->nid, port->id);
+	snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input",
+						pin->nid, port->id);
 	kc->name = devm_kstrdup(&edev->hdac.dev, kc_name, GFP_KERNEL);
 	if (!kc->name)
 		return -ENOMEM;
-- 
2.14.2

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

* [PATCH 10/11] ASoC: hdac_hdmi: Fix possible NULL pointer dereference
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (8 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 09/11] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix possible NULL pointer dereference" to the asoc tree Mark Brown
  2017-11-07 10:46 ` [PATCH 11/11] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure Guneshwor Singh
  2017-11-08 14:15 ` [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Vinod Koul
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, Liam Girdwood,
	Vinod Koul, Subhransu S. Prusty

From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>

Pointers hdac_hdmi_pcm and hda_device_id can be NULL, so add check for
valid pointer to avoid NULL pointer dereference.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 6f3ff15c0962..0c0aa6182502 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1895,6 +1895,9 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_port *port;
 
+	if (!pcm)
+		return;
+
 	if (list_empty(&pcm->port_list))
 		return;
 
@@ -1913,6 +1916,9 @@ static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
 	struct hdac_hdmi_priv *hdmi = edev->private_data;
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 
+	if (!pcm)
+		return false;
+
 	if (list_empty(&pcm->port_list))
 		return false;
 
@@ -1926,6 +1932,9 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_port *port;
 
+	if (!pcm)
+		return 0;
+
 	if (list_empty(&pcm->port_list))
 		return 0;
 
@@ -1979,6 +1988,9 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
 	hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached;
 	hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc;
 
+	if (!hdac_id)
+		return -ENODEV;
+
 	if (hdac_id->driver_data)
 		hdmi_priv->drv_data =
 			(struct hdac_hdmi_drv_data *)hdac_id->driver_data;
-- 
2.14.2

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

* [PATCH 11/11] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (9 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 10/11] ASoC: hdac_hdmi: Fix possible NULL pointer dereference Guneshwor Singh
@ 2017-11-07 10:46 ` Guneshwor Singh
  2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure" to the asoc tree Mark Brown
  2017-11-08 14:15 ` [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Vinod Koul
  11 siblings, 1 reply; 24+ messages in thread
From: Guneshwor Singh @ 2017-11-07 10:46 UTC (permalink / raw)
  To: ALSA ML, Mark Brown
  Cc: Takashi Iwai, Guneshwor Singh, Patches Audio, Liam Girdwood,
	Vinod Koul, Subhransu S. Prusty

From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>

During failure, widgets in cvt_list and pin_list are not freed. So fix
the possible memory leak by freeing them when failure occurs.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 0c0aa6182502..f3b4f4dfae6a 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1453,6 +1453,8 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
 	int i, num_nodes;
 	struct hdac_device *hdac = &edev->hdac;
 	struct hdac_hdmi_priv *hdmi = edev->private_data;
+	struct hdac_hdmi_cvt *temp_cvt, *cvt_next;
+	struct hdac_hdmi_pin *temp_pin, *pin_next;
 	int ret;
 
 	hdac_hdmi_skl_enable_all_pins(hdac);
@@ -1482,32 +1484,54 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
 		case AC_WID_AUD_OUT:
 			ret = hdac_hdmi_add_cvt(edev, nid);
 			if (ret < 0)
-				return ret;
+				goto free_widgets;
 			break;
 
 		case AC_WID_PIN:
 			ret = hdac_hdmi_add_pin(edev, nid);
 			if (ret < 0)
-				return ret;
+				goto free_widgets;
 			break;
 		}
 	}
 
 	hdac->end_nid = nid;
 
-	if (!hdmi->num_pin || !hdmi->num_cvt)
-		return -EIO;
+	if (!hdmi->num_pin || !hdmi->num_cvt) {
+		ret = -EIO;
+		goto free_widgets;
+	}
 
 	ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt);
 	if (ret) {
 		dev_err(&hdac->dev, "Failed to create dais with err: %d\n",
 							ret);
-		return ret;
+		goto free_widgets;
 	}
 
 	*num_dais = hdmi->num_cvt;
+	ret = hdac_hdmi_init_dai_map(edev);
+	if (ret < 0)
+		goto free_widgets;
 
-	return hdac_hdmi_init_dai_map(edev);
+	return ret;
+
+free_widgets:
+	list_for_each_entry_safe(temp_cvt, cvt_next, &hdmi->cvt_list, head) {
+		list_del(&temp_cvt->head);
+		kfree(temp_cvt->name);
+		kfree(temp_cvt);
+	}
+
+	list_for_each_entry_safe(temp_pin, pin_next, &hdmi->pin_list, head) {
+		for (i = 0; i < temp_pin->num_ports; i++)
+			temp_pin->ports[i].pin = NULL;
+		kfree(temp_pin->ports);
+		list_del(&temp_pin->head);
+		kfree(temp_pin);
+	}
+
+	return ret;
 }
 
 static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
-- 
2.14.2

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

* Re: [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver
  2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
                   ` (10 preceding siblings ...)
  2017-11-07 10:46 ` [PATCH 11/11] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure Guneshwor Singh
@ 2017-11-08 14:15 ` Vinod Koul
  11 siblings, 0 replies; 24+ messages in thread
From: Vinod Koul @ 2017-11-08 14:15 UTC (permalink / raw)
  To: Guneshwor Singh
  Cc: Takashi Iwai, Liam Girdwood, ALSA ML, Mark Brown, Patches Audio

On Tue, Nov 07, 2017 at 04:16:15PM +0530, Guneshwor Singh wrote:
> This series include couple of bug fixes which include memory leak fixes, null
> pointer dereference fixes, fixes for errors generated by static checker, updown
> mixer module ipc format fix and use module uuid instead of module id which is
> required for module pins.

Acked-By: Vinod Koul <vinod.koul@intel.com>

> Guneshwor Singh (2):
>   ASoC: Intel: Skylake: Fix updown mixer module format
>   ASoC: Intel: Skylake: Add channel map in updown mixer module IPC
> 
> Pankaj Bharadiya (3):
>   ASoC: Intel: Skylake: Fix potential NULL pointer dereference
>   ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case
>   ASoC: Intel: Skylake: Check for NHLT ACPI header signature
> 
> Sriram Periyasamy (2):
>   ASoC: Intel: Skylake: Optimize UUID handling to fill pin info
>   ASoC: Intel: Skylake: Add dynamic module id support
> 
> Subhransu S. Prusty (4):
>   ASoC: Intel: Skylake: Remove second shim read in register_poll
>   ASoC: hdac_hdmi: Fix static checker warning for sprintf usage
>   ASoC: hdac_hdmi: Fix possible NULL pointer dereference
>   ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure
> 
>  sound/soc/codecs/hdac_hdmi.c            | 51 ++++++++++++++++++++++----
>  sound/soc/intel/common/sst-dsp.c        |  4 +-
>  sound/soc/intel/skylake/skl-messages.c  |  9 +----
>  sound/soc/intel/skylake/skl-nhlt.c      |  9 +++++
>  sound/soc/intel/skylake/skl-pcm.c       |  3 +-
>  sound/soc/intel/skylake/skl-sst-utils.c | 15 ++++++--
>  sound/soc/intel/skylake/skl-topology.c  | 65 +++++++++++++++++++++------------
>  sound/soc/intel/skylake/skl-topology.h  |  3 +-
>  8 files changed, 112 insertions(+), 47 deletions(-)
> 
> -- 
> 2.14.2
> 

-- 
~Vinod

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

* Applied "ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure" to the asoc tree
  2017-11-07 10:46 ` [PATCH 11/11] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure Guneshwor Singh
@ 2017-11-08 21:32   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:32 UTC (permalink / raw)
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul, Subhransu S. Prusty

The patch

   ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 1c0a7de226660b0306b54aaf2cb52312e74723eb Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 7 Nov 2017 16:16:26 +0530
Subject: [PATCH] ASoC: hdac_hdmi: Fix possible memory leak on parse and map
 nid failure

During failure, widgets in cvt_list and pin_list are not freed. So fix
the possible memory leak by freeing them when failure occurs.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/hdac_hdmi.c | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 0c0aa6182502..f3b4f4dfae6a 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1453,6 +1453,8 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
 	int i, num_nodes;
 	struct hdac_device *hdac = &edev->hdac;
 	struct hdac_hdmi_priv *hdmi = edev->private_data;
+	struct hdac_hdmi_cvt *temp_cvt, *cvt_next;
+	struct hdac_hdmi_pin *temp_pin, *pin_next;
 	int ret;
 
 	hdac_hdmi_skl_enable_all_pins(hdac);
@@ -1482,32 +1484,54 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev,
 		case AC_WID_AUD_OUT:
 			ret = hdac_hdmi_add_cvt(edev, nid);
 			if (ret < 0)
-				return ret;
+				goto free_widgets;
 			break;
 
 		case AC_WID_PIN:
 			ret = hdac_hdmi_add_pin(edev, nid);
 			if (ret < 0)
-				return ret;
+				goto free_widgets;
 			break;
 		}
 	}
 
 	hdac->end_nid = nid;
 
-	if (!hdmi->num_pin || !hdmi->num_cvt)
-		return -EIO;
+	if (!hdmi->num_pin || !hdmi->num_cvt) {
+		ret = -EIO;
+		goto free_widgets;
+	}
 
 	ret = hdac_hdmi_create_dais(hdac, dais, hdmi, hdmi->num_cvt);
 	if (ret) {
 		dev_err(&hdac->dev, "Failed to create dais with err: %d\n",
 							ret);
-		return ret;
+		goto free_widgets;
 	}
 
 	*num_dais = hdmi->num_cvt;
+	ret = hdac_hdmi_init_dai_map(edev);
+	if (ret < 0)
+		goto free_widgets;
 
-	return hdac_hdmi_init_dai_map(edev);
+	return ret;
+
+free_widgets:
+	list_for_each_entry_safe(temp_cvt, cvt_next, &hdmi->cvt_list, head) {
+		list_del(&temp_cvt->head);
+		kfree(temp_cvt->name);
+		kfree(temp_cvt);
+	}
+
+	list_for_each_entry_safe(temp_pin, pin_next, &hdmi->pin_list, head) {
+		for (i = 0; i < temp_pin->num_ports; i++)
+			temp_pin->ports[i].pin = NULL;
+		kfree(temp_pin->ports);
+		list_del(&temp_pin->head);
+		kfree(temp_pin);
+	}
+
+	return ret;
 }
 
 static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
-- 
2.15.0

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

* Applied "ASoC: hdac_hdmi: Fix possible NULL pointer dereference" to the asoc tree
  2017-11-07 10:46 ` [PATCH 10/11] ASoC: hdac_hdmi: Fix possible NULL pointer dereference Guneshwor Singh
@ 2017-11-08 21:32   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:32 UTC (permalink / raw)
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul, Subhransu S. Prusty

The patch

   ASoC: hdac_hdmi: Fix possible NULL pointer dereference

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From eb50fa1739a63cc4b202b40a62d71055a2d7b80c Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 7 Nov 2017 16:16:25 +0530
Subject: [PATCH] ASoC: hdac_hdmi: Fix possible NULL pointer dereference

Pointers hdac_hdmi_pcm and hda_device_id can be NULL, so add check for
valid pointer to avoid NULL pointer dereference.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/hdac_hdmi.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 6f3ff15c0962..0c0aa6182502 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1895,6 +1895,9 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_port *port;
 
+	if (!pcm)
+		return;
+
 	if (list_empty(&pcm->port_list))
 		return;
 
@@ -1913,6 +1916,9 @@ static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
 	struct hdac_hdmi_priv *hdmi = edev->private_data;
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 
+	if (!pcm)
+		return false;
+
 	if (list_empty(&pcm->port_list))
 		return false;
 
@@ -1926,6 +1932,9 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx)
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_port *port;
 
+	if (!pcm)
+		return 0;
+
 	if (list_empty(&pcm->port_list))
 		return 0;
 
@@ -1979,6 +1988,9 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev)
 	hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached;
 	hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc;
 
+	if (!hdac_id)
+		return -ENODEV;
+
 	if (hdac_id->driver_data)
 		hdmi_priv->drv_data =
 			(struct hdac_hdmi_drv_data *)hdac_id->driver_data;
-- 
2.15.0

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

* Applied "ASoC: hdac_hdmi: Fix static checker warning for sprintf usage" to the asoc tree
  2017-11-07 10:46 ` [PATCH 09/11] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage Guneshwor Singh
@ 2017-11-08 21:32   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:32 UTC (permalink / raw)
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul, Subhransu S. Prusty

The patch

   ASoC: hdac_hdmi: Fix static checker warning for sprintf usage

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 70e97a2d9c5266487dfec4cade28f8e587927f04 Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Tue, 7 Nov 2017 16:16:24 +0530
Subject: [PATCH] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage

Use snprintf instead of sprintf to shut the warning.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/hdac_hdmi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index e824d47cc22b..6f3ff15c0962 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -942,7 +942,8 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev,
 	if (!se)
 		return -ENOMEM;
 
-	sprintf(kc_name, "Pin %d port %d Input", pin->nid, port->id);
+	snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input",
+						pin->nid, port->id);
 	kc->name = devm_kstrdup(&edev->hdac.dev, kc_name, GFP_KERNEL);
 	if (!kc->name)
 		return -ENOMEM;
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Add dynamic module id support" to the asoc tree
  2017-11-07 10:46 ` [PATCH 08/11] ASoC: Intel: Skylake: Add dynamic module id support Guneshwor Singh
@ 2017-11-08 21:32   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:32 UTC (permalink / raw)
  To: Sriram Periyasamy
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul

The patch

   ASoC: Intel: Skylake: Add dynamic module id support

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From d956147473ec1843c2660a89ef0fba80b66c6657 Mon Sep 17 00:00:00 2001
From: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Date: Tue, 7 Nov 2017 16:16:23 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add dynamic module id support

Module id is a property of firmware manifest and can vary between
platforms so use the uuid instead of module id for pins.

Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-topology.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 90f8c839bcef..b590742c5a7a 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2054,6 +2054,8 @@ static int skl_tplg_fill_pin(struct device *dev,
 			struct skl_module_pin *m_pin,
 			int pin_index)
 {
+	int ret;
+
 	switch (tkn_elem->token) {
 	case SKL_TKN_U32_PIN_MOD_ID:
 		m_pin[pin_index].id.module_id = tkn_elem->value;
@@ -2063,6 +2065,14 @@ static int skl_tplg_fill_pin(struct device *dev,
 		m_pin[pin_index].id.instance_id = tkn_elem->value;
 		break;
 
+	case SKL_TKN_UUID:
+		ret = skl_tplg_get_uuid(dev, m_pin[pin_index].id.mod_uuid.b,
+			(struct snd_soc_tplg_vendor_uuid_elem *)tkn_elem);
+		if (ret < 0)
+			return ret;
+
+		break;
+
 	default:
 		dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
 		return -EINVAL;
@@ -2487,6 +2497,7 @@ static int skl_tplg_get_token(struct device *dev,
 
 	case SKL_TKN_U32_PIN_MOD_ID:
 	case SKL_TKN_U32_PIN_INST_ID:
+	case SKL_TKN_UUID:
 		ret = skl_tplg_fill_pins_info(dev,
 				mconfig, tkn_elem, dir,
 				pin_index);
@@ -2549,6 +2560,7 @@ static int skl_tplg_get_tokens(struct device *dev,
 	struct snd_soc_tplg_vendor_value_elem *tkn_elem;
 	int tkn_count = 0, ret;
 	int off = 0, tuple_size = 0;
+	bool is_module_guid = true;
 
 	if (block_size <= 0)
 		return -EINVAL;
@@ -2564,8 +2576,15 @@ static int skl_tplg_get_tokens(struct device *dev,
 			continue;
 
 		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
-			ret = skl_tplg_get_uuid(dev, mconfig->guid,
-					array->uuid);
+			if (is_module_guid) {
+				ret = skl_tplg_get_uuid(dev, mconfig->guid,
+							array->uuid);
+				is_module_guid = false;
+			} else {
+				ret = skl_tplg_get_token(dev, array->value, skl,
+							 mconfig);
+			}
+
 			if (ret < 0)
 				return ret;
 
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Optimize UUID handling to fill pin info" to the asoc tree
  2017-11-07 10:46 ` [PATCH 07/11] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Sriram Periyasamy
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul

The patch

   ASoC: Intel: Skylake: Optimize UUID handling to fill pin info

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 22ebd6666efd8663a06715a052f74b6a7e904dc3 Mon Sep 17 00:00:00 2001
From: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Date: Tue, 7 Nov 2017 16:16:22 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info

Modify skl_tplg_get_uuid() to copy just UUID rather than only
for module UUID and skl_tplg_fill_pin() to fill the pin info
which can include UUID token also.

Signed-off-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-topology.c | 46 +++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 1200b7c6af56..90f8c839bcef 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -2036,21 +2036,35 @@ static int skl_tplg_add_pipe(struct device *dev,
 	return 0;
 }
 
-static int skl_tplg_fill_pin(struct device *dev, u32 tkn,
+static int skl_tplg_get_uuid(struct device *dev, u8 *guid,
+	      struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
+{
+	if (uuid_tkn->token == SKL_TKN_UUID) {
+		memcpy(guid, &uuid_tkn->uuid, 16);
+		return 0;
+	}
+
+	dev_err(dev, "Not an UUID token %d\n", uuid_tkn->token);
+
+	return -EINVAL;
+}
+
+static int skl_tplg_fill_pin(struct device *dev,
+			struct snd_soc_tplg_vendor_value_elem *tkn_elem,
 			struct skl_module_pin *m_pin,
-			int pin_index, u32 value)
+			int pin_index)
 {
-	switch (tkn) {
+	switch (tkn_elem->token) {
 	case SKL_TKN_U32_PIN_MOD_ID:
-		m_pin[pin_index].id.module_id = value;
+		m_pin[pin_index].id.module_id = tkn_elem->value;
 		break;
 
 	case SKL_TKN_U32_PIN_INST_ID:
-		m_pin[pin_index].id.instance_id = value;
+		m_pin[pin_index].id.instance_id = tkn_elem->value;
 		break;
 
 	default:
-		dev_err(dev, "%d Not a pin token\n", value);
+		dev_err(dev, "%d Not a pin token\n", tkn_elem->token);
 		return -EINVAL;
 	}
 
@@ -2083,9 +2097,7 @@ static int skl_tplg_fill_pins_info(struct device *dev,
 		return -EINVAL;
 	}
 
-	ret = skl_tplg_fill_pin(dev, tkn_elem->token,
-			m_pin, pin_count, tkn_elem->value);
-
+	ret = skl_tplg_fill_pin(dev, tkn_elem, m_pin, pin_count);
 	if (ret < 0)
 		return ret;
 
@@ -2170,19 +2182,6 @@ static int skl_tplg_widget_fill_fmt(struct device *dev,
 	return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val);
 }
 
-static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig,
-	      struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
-{
-	if (uuid_tkn->token == SKL_TKN_UUID)
-		memcpy(&mconfig->guid, &uuid_tkn->uuid, 16);
-	else {
-		dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static void skl_tplg_fill_pin_dynamic_val(
 		struct skl_module_pin *mpin, u32 pin_count, u32 value)
 {
@@ -2565,7 +2564,8 @@ static int skl_tplg_get_tokens(struct device *dev,
 			continue;
 
 		case SND_SOC_TPLG_TUPLE_TYPE_UUID:
-			ret = skl_tplg_get_uuid(dev, mconfig, array->uuid);
+			ret = skl_tplg_get_uuid(dev, mconfig->guid,
+					array->uuid);
 			if (ret < 0)
 				return ret;
 
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Check for NHLT ACPI header signature" to the asoc tree
  2017-11-07 10:46 ` [PATCH 06/11] ASoC: Intel: Skylake: Check for NHLT ACPI header signature Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Pankaj Bharadiya
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul

The patch

   ASoC: Intel: Skylake: Check for NHLT ACPI header signature

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 3b47c9dc75be097bc0e2f3ac4b176fbf3eed85f2 Mon Sep 17 00:00:00 2001
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Date: Tue, 7 Nov 2017 16:16:21 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Check for NHLT ACPI header signature

In certain buggy BIOS acpi_evaluate_dsm() may not return the correct
NHLT table, so check the NHLT table header signature before accessing
it.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-nhlt.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index e7d766d56c8e..d14c50a60289 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -20,6 +20,8 @@
 #include <linux/pci.h>
 #include "skl.h"
 
+#define NHLT_ACPI_HEADER_SIG	"NHLT"
+
 /* Unique identification for getting NHLT blobs */
 static guid_t osc_guid =
 	GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
@@ -45,6 +47,13 @@ struct nhlt_acpi_table *skl_nhlt_init(struct device *dev)
 				memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
 				MEMREMAP_WB);
 		ACPI_FREE(obj);
+		if (nhlt_table && (strncmp(nhlt_table->header.signature,
+					NHLT_ACPI_HEADER_SIG,
+					strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
+			memunmap(nhlt_table);
+			dev_err(dev, "NHLT ACPI header signature incorrect\n");
+			return NULL;
+		}
 		return nhlt_table;
 	}
 
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case" to the asoc tree
  2017-11-07 10:46 ` [PATCH 04/11] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Pankaj Bharadiya
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul

The patch

   ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From f8e066521192c7debe59127d90abbe2773577e25 Mon Sep 17 00:00:00 2001
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Date: Tue, 7 Nov 2017 16:16:19 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure
 case

In the loop that adds the uuid_module to the uuid_list list, allocated
memory is not properly freed in the error path free uuid_list whenever
any of the memory allocation in the loop fails to avoid memory leak.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-sst-utils.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
index 369ef7ce981c..8ff89280d9fd 100644
--- a/sound/soc/intel/skylake/skl-sst-utils.c
+++ b/sound/soc/intel/skylake/skl-sst-utils.c
@@ -251,6 +251,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 	struct uuid_module *module;
 	struct firmware stripped_fw;
 	unsigned int safe_file;
+	int ret = 0;
 
 	/* Get the FW pointer to derive ADSP header */
 	stripped_fw.data = fw->data;
@@ -299,8 +300,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 
 	for (i = 0; i < num_entry; i++, mod_entry++) {
 		module = kzalloc(sizeof(*module), GFP_KERNEL);
-		if (!module)
-			return -ENOMEM;
+		if (!module) {
+			ret = -ENOMEM;
+			goto free_uuid_list;
+		}
 
 		uuid_bin = (uuid_le *)mod_entry->uuid.id;
 		memcpy(&module->uuid, uuid_bin, sizeof(module->uuid));
@@ -311,8 +314,8 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 		size = sizeof(int) * mod_entry->instance_max_count;
 		module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
 		if (!module->instance_id) {
-			kfree(module);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto free_uuid_list;
 		}
 
 		list_add_tail(&module->list, &skl->uuid_list);
@@ -323,6 +326,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 	}
 
 	return 0;
+
+free_uuid_list:
+	skl_freeup_uuid_list(skl);
+	return ret;
 }
 
 void skl_freeup_uuid_list(struct skl_sst *ctx)
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Fix potential NULL pointer dereference" to the asoc tree
  2017-11-07 10:46 ` [PATCH 03/11] ASoC: Intel: Skylake: Fix potential NULL pointer dereference Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Pankaj Bharadiya
  Cc: alsa-devel, Takashi Iwai, Guneshwor Singh, Liam Girdwood,
	Patches Audio, Mark Brown, Vinod Koul

The patch

   ASoC: Intel: Skylake: Fix potential NULL pointer dereference

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 0265ddd7b713bd8b68a9ec451761bcb87bbac4b3 Mon Sep 17 00:00:00 2001
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Date: Tue, 7 Nov 2017 16:16:18 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix potential NULL pointer dereference

Pointer 'mconfig' returned from call to skl_tplg_fe_get_cpr_module() can
be NULL. So check for the valid pointer before dereferencing.

Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-pcm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 2b1e513b1680..a3cb204e9640 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -355,7 +355,8 @@ static void skl_pcm_close(struct snd_pcm_substream *substream,
 	}
 
 	mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
-	skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
+	if (mconfig)
+		skl_tplg_d0i3_put(skl, mconfig->d0i3_caps);
 
 	kfree(dma_params);
 }
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Add channel map in updown mixer module IPC" to the asoc tree
  2017-11-07 10:46 ` [PATCH 02/11] ASoC: Intel: Skylake: Add channel map in updown mixer module IPC Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Guneshwor Singh
  Cc: alsa-devel, Takashi Iwai, Patches Audio, Liam Girdwood,
	Vinod Koul, Mark Brown

The patch

   ASoC: Intel: Skylake: Add channel map in updown mixer module IPC

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From da3417fe1f6d54c864b05fd5710979bdffe78034 Mon Sep 17 00:00:00 2001
From: Guneshwor Singh <guneshwor.o.singh@intel.com>
Date: Tue, 7 Nov 2017 16:16:17 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Add channel map in updown mixer module
 IPC

DSP expects channel map to be sent in the IPC for updown mixer module.
So add ch_map info in updown mixer module config.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-messages.c | 1 +
 sound/soc/intel/skylake/skl-topology.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index 55414be23b82..b9c205c8bb73 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -706,6 +706,7 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
 	skl_set_base_module_format(ctx,	mconfig,
 		(struct skl_base_cfg *)mixer_mconfig);
 	mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
+	mixer_mconfig->ch_map = fmt->ch_map;
 }
 
 /*
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index 16cea466018c..bc3c29161ed0 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -161,6 +161,7 @@ struct skl_up_down_mixer_cfg {
 	u32 coeff_sel;
 	/* Pass the user coeff in this array */
 	s32 coeff[UP_DOWN_MIXER_MAX_COEFF];
+	u32 ch_map;
 } __packed;
 
 struct skl_algo_cfg {
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Fix updown mixer module format" to the asoc tree
  2017-11-07 10:46 ` [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format Guneshwor Singh
@ 2017-11-08 21:33   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-11-08 21:33 UTC (permalink / raw)
  To: Guneshwor Singh
  Cc: alsa-devel, Takashi Iwai, Patches Audio, Liam Girdwood,
	Vinod Koul, Mark Brown

The patch

   ASoC: Intel: Skylake: Fix updown mixer module format

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 3e1b96c80f1a73594b2123173c551bb0fc829b21 Mon Sep 17 00:00:00 2001
From: Guneshwor Singh <guneshwor.o.singh@intel.com>
Date: Tue, 7 Nov 2017 16:16:16 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix updown mixer module format

DSP expects length of the coefficient for updown mixer module to be 8.
So fix the max coefficient length and since we are using default values
for coefficient select which is zero, we need not explicitly initialize
it.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/skylake/skl-messages.c | 8 --------
 sound/soc/intel/skylake/skl-topology.h | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index 89f70133c8e4..55414be23b82 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -702,18 +702,10 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
 	struct skl_module *module = mconfig->module;
 	struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
 	struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
-	int i = 0;
 
 	skl_set_base_module_format(ctx,	mconfig,
 		(struct skl_base_cfg *)mixer_mconfig);
 	mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
-
-	/* Select F/W default coefficient */
-	mixer_mconfig->coeff_sel = 0x0;
-
-	/* User coeff, don't care since we are selecting F/W defaults */
-	for (i = 0; i < UP_DOWN_MIXER_MAX_COEFF; i++)
-		mixer_mconfig->coeff[i] = 0xDEADBEEF;
 }
 
 /*
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index 2717db92036b..16cea466018c 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -34,7 +34,7 @@
 #define MAX_FIXED_DMIC_PARAMS_SIZE 727
 
 /* Maximum number of coefficients up down mixer module */
-#define UP_DOWN_MIXER_MAX_COEFF		6
+#define UP_DOWN_MIXER_MAX_COEFF		8
 
 #define MODULE_MAX_IN_PINS	8
 #define MODULE_MAX_OUT_PINS	8
-- 
2.15.0

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

* Applied "ASoC: Intel: Skylake: Remove second shim read in register_poll" to the asoc tree
  2017-11-07 10:46 ` [PATCH 05/11] ASoC: Intel: Skylake: Remove second shim read in register_poll Guneshwor Singh
@ 2017-12-06 17:49   ` Mark Brown
  0 siblings, 0 replies; 24+ messages in thread
From: Mark Brown @ 2017-12-06 17:49 UTC (permalink / raw)
  Cc: alsa-devel, Vinod Koul, Guneshwor Singh, Patches Audio,
	Liam Girdwood, Takashi Iwai, Mark Brown, Subhransu S. Prusty

The patch

   ASoC: Intel: Skylake: Remove second shim read in register_poll

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From b2ca3bdd07f68ca63fdb8e45f1fe039ba6af54a2 Mon Sep 17 00:00:00 2001
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Date: Wed, 6 Dec 2017 16:34:01 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Remove second shim read in
 register_poll

No need to read the register again if the value read has already matched
the target during the loop. So remove the second shim read.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/common/sst-dsp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/soc/intel/common/sst-dsp.c b/sound/soc/intel/common/sst-dsp.c
index 11c0805393ff..fd82f4b1d4a0 100644
--- a/sound/soc/intel/common/sst-dsp.c
+++ b/sound/soc/intel/common/sst-dsp.c
@@ -269,7 +269,7 @@ int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
 	 */
 
 	timeout = jiffies + msecs_to_jiffies(time);
-	while (((sst_dsp_shim_read_unlocked(ctx, offset) & mask) != target)
+	while ((((reg = sst_dsp_shim_read_unlocked(ctx, offset)) & mask) != target)
 		&& time_before(jiffies, timeout)) {
 		k++;
 		if (k > 10)
@@ -278,8 +278,6 @@ int sst_dsp_register_poll(struct sst_dsp *ctx, u32 offset, u32 mask,
 		usleep_range(s, 2*s);
 	}
 
-	reg = sst_dsp_shim_read_unlocked(ctx, offset);
-
 	if ((reg & mask) == target) {
 		dev_dbg(ctx->dev, "FW Poll Status: reg=%#x %s successful\n",
 					reg, operation);
-- 
2.15.0

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

end of thread, other threads:[~2017-12-06 17:49 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 10:46 [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Guneshwor Singh
2017-11-07 10:46 ` [PATCH 01/11] ASoC: Intel: Skylake: Fix updown mixer module format Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix updown mixer module format" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 02/11] ASoC: Intel: Skylake: Add channel map in updown mixer module IPC Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Add channel map in updown mixer module IPC" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 03/11] ASoC: Intel: Skylake: Fix potential NULL pointer dereference Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix potential NULL pointer dereference" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 04/11] ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 05/11] ASoC: Intel: Skylake: Remove second shim read in register_poll Guneshwor Singh
2017-12-06 17:49   ` Applied "ASoC: Intel: Skylake: Remove second shim read in register_poll" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 06/11] ASoC: Intel: Skylake: Check for NHLT ACPI header signature Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Check for NHLT ACPI header signature" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 07/11] ASoC: Intel: Skylake: Optimize UUID handling to fill pin info Guneshwor Singh
2017-11-08 21:33   ` Applied "ASoC: Intel: Skylake: Optimize UUID handling to fill pin info" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 08/11] ASoC: Intel: Skylake: Add dynamic module id support Guneshwor Singh
2017-11-08 21:32   ` Applied "ASoC: Intel: Skylake: Add dynamic module id support" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 09/11] ASoC: hdac_hdmi: Fix static checker warning for sprintf usage Guneshwor Singh
2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix static checker warning for sprintf usage" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 10/11] ASoC: hdac_hdmi: Fix possible NULL pointer dereference Guneshwor Singh
2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix possible NULL pointer dereference" to the asoc tree Mark Brown
2017-11-07 10:46 ` [PATCH 11/11] ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure Guneshwor Singh
2017-11-08 21:32   ` Applied "ASoC: hdac_hdmi: Fix possible memory leak on parse and map nid failure" to the asoc tree Mark Brown
2017-11-08 14:15 ` [PATCH 00/11] ASoC: Intel: Skylake: Bug fixes for skylake driver Vinod Koul

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.