2018-12-27 17:53:01 +08:00
|
|
|
From 1a08abdcd22ab0b62301bfd2894ffab5ac016bf9 Mon Sep 17 00:00:00 2001
|
2018-10-16 02:05:43 +08:00
|
|
|
From: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
|
|
|
|
Date: Wed, 6 Sep 2017 14:04:58 +0530
|
2018-12-27 17:53:01 +08:00
|
|
|
Subject: [PATCH 210/296] ASoC: Intel: Skylake: Fix error handling in
|
2018-10-16 02:05:43 +08:00
|
|
|
cnl_sdw_hw_params()
|
|
|
|
|
|
|
|
There are bunch of error paths where allocated resources are not freed
|
|
|
|
before returning.
|
|
|
|
|
|
|
|
Add the missing error handling to free up the allocated resources.
|
|
|
|
|
|
|
|
Change-Id: I2b7b3e901d6878f951823661cfc32f03167c32fa
|
|
|
|
Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
|
|
|
|
Reviewed-on:
|
|
|
|
Reviewed-by: Prusty, Subhransu S <subhransu.s.prusty@intel.com>
|
|
|
|
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
|
2018-10-30 05:21:52 +08:00
|
|
|
Reviewed-by: audio_build
|
2018-10-16 02:05:43 +08:00
|
|
|
Tested-by: Sm, Bhadur A <bhadur.a.sm@intel.com>
|
|
|
|
---
|
|
|
|
sound/soc/intel/skylake/skl-sdw-pcm.c | 34 ++++++++++++++++++---------
|
|
|
|
1 file changed, 23 insertions(+), 11 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/sound/soc/intel/skylake/skl-sdw-pcm.c b/sound/soc/intel/skylake/skl-sdw-pcm.c
|
|
|
|
index 955c952cc4bb..fb3186a5a35f 100644
|
|
|
|
--- a/sound/soc/intel/skylake/skl-sdw-pcm.c
|
|
|
|
+++ b/sound/soc/intel/skylake/skl-sdw-pcm.c
|
|
|
|
@@ -141,6 +141,7 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct skl_pipe_params p_params = {0};
|
|
|
|
struct skl_module_cfg *m_cfg;
|
|
|
|
int i, upscale_factor = 16;
|
|
|
|
+ int nr_port;
|
|
|
|
|
|
|
|
p_params.s_fmt = snd_pcm_format_width(params_format(params));
|
|
|
|
p_params.ch = params_channels(params);
|
|
|
|
@@ -168,13 +169,14 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
if (!dma->port)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
- for (i = 0; i < dma->nr_ports; i++) {
|
|
|
|
+ for (nr_port = 0; nr_port < dma->nr_ports; nr_port++) {
|
|
|
|
/* Dynamically alloc port and PDI streams for this DAI */
|
|
|
|
- dma->port[i] = cnl_sdw_alloc_port(dma->mstr, channels,
|
|
|
|
+ dma->port[nr_port] = cnl_sdw_alloc_port(dma->mstr, channels,
|
|
|
|
direction, dma->stream_type);
|
|
|
|
- if (!dma->port[i]) {
|
|
|
|
+ if (!dma->port[nr_port]) {
|
|
|
|
dev_err(dai->dev, "Unable to allocate port\n");
|
|
|
|
- return -EINVAL;
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ goto free_dma_port;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -182,7 +184,8 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
m_cfg = skl_tplg_be_get_cpr_module(dai, substream->stream);
|
|
|
|
if (!m_cfg) {
|
|
|
|
dev_err(dai->dev, "BE Copier not found\n");
|
|
|
|
- return -EINVAL;
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ goto free_dma_port;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_cfg->sdw_agg_enable)
|
|
|
|
@@ -192,7 +195,7 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
dma->port[0]->pdi_stream->sdw_pdi_num;
|
|
|
|
ret = skl_tplg_be_update_params(dai, &p_params);
|
|
|
|
if (ret)
|
|
|
|
- return ret;
|
|
|
|
+ goto free_dma_port;
|
|
|
|
|
|
|
|
|
|
|
|
stream_config.frame_rate = params_rate(params);
|
|
|
|
@@ -216,13 +219,14 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
dma->stream_tag);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dai->dev, "Unable to configure the stream\n");
|
|
|
|
- return ret;
|
|
|
|
+ goto free_dma_port;
|
|
|
|
}
|
|
|
|
port_cfg = kcalloc(dma->nr_ports, sizeof(struct sdw_port_cfg),
|
|
|
|
GFP_KERNEL);
|
|
|
|
- if (!port_cfg)
|
|
|
|
- return -ENOMEM;
|
|
|
|
-
|
|
|
|
+ if (!port_cfg) {
|
|
|
|
+ ret = -ENOMEM;
|
|
|
|
+ goto free_dma_port;
|
|
|
|
+ }
|
|
|
|
port_config.num_ports = dma->nr_ports;
|
|
|
|
port_config.port_cfg = port_cfg;
|
|
|
|
|
|
|
|
@@ -238,10 +242,18 @@ int cnl_sdw_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
ret = sdw_config_port(dma->mstr, NULL, &port_config, dma->stream_tag);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(dai->dev, "Unable to configure port\n");
|
|
|
|
- return ret;
|
|
|
|
+ goto free_port_cfg;
|
|
|
|
}
|
|
|
|
dma->stream_state = STREAM_STATE_CONFIG_STREAM;
|
|
|
|
return 0;
|
|
|
|
+
|
|
|
|
+free_port_cfg:
|
|
|
|
+ kfree(port_cfg);
|
|
|
|
+free_dma_port:
|
|
|
|
+ while (nr_port--)
|
|
|
|
+ cnl_sdw_free_port(dma->mstr, dma->port[nr_port]->port_num);
|
|
|
|
+ kfree(dma->port);
|
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cnl_sdw_hw_free(struct snd_pcm_substream *substream,
|
|
|
|
--
|
2018-12-27 17:53:01 +08:00
|
|
|
2.19.1
|
2018-10-16 02:05:43 +08:00
|
|
|
|