Commit d09a7db4 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsnd: care return value from rsnd_node_fixed_index()

Renesas Sound is very complex, and thus it needs to use
rsnd_node_fixed_index() to know enabled pin index.

It returns error if strange pin was selected,
but some codes didn't check it.

This patch 1) indicates error message, 2) check return
value.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pmlbgn5t.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c1d97b86
...@@ -1159,6 +1159,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, ...@@ -1159,6 +1159,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name,
struct device_node *capture) struct device_node *capture)
{ {
struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
struct device *dev = rsnd_priv_to_dev(priv);
struct device_node *np; struct device_node *np;
int i; int i;
...@@ -1169,7 +1170,11 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, ...@@ -1169,7 +1170,11 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name,
for_each_child_of_node(node, np) { for_each_child_of_node(node, np) {
struct rsnd_mod *mod; struct rsnd_mod *mod;
i = rsnd_node_fixed_index(np, name, i); i = rsnd_node_fixed_index(dev, np, name, i);
if (i < 0) {
of_node_put(np);
break;
}
mod = mod_get(priv, i); mod = mod_get(priv, i);
...@@ -1183,7 +1188,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, ...@@ -1183,7 +1188,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name,
of_node_put(node); of_node_put(node);
} }
int rsnd_node_fixed_index(struct device_node *node, char *name, int idx) int rsnd_node_fixed_index(struct device *dev, struct device_node *node, char *name, int idx)
{ {
char node_name[16]; char node_name[16];
...@@ -1210,6 +1215,8 @@ int rsnd_node_fixed_index(struct device_node *node, char *name, int idx) ...@@ -1210,6 +1215,8 @@ int rsnd_node_fixed_index(struct device_node *node, char *name, int idx)
return idx; return idx;
} }
dev_err(dev, "strange node numbering (%s)",
of_node_full_name(node));
return -EINVAL; return -EINVAL;
} }
...@@ -1221,10 +1228,8 @@ int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name ...@@ -1221,10 +1228,8 @@ int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name
i = 0; i = 0;
for_each_child_of_node(node, np) { for_each_child_of_node(node, np) {
i = rsnd_node_fixed_index(np, name, i); i = rsnd_node_fixed_index(dev, np, name, i);
if (i < 0) { if (i < 0) {
dev_err(dev, "strange node numbering (%s)",
of_node_full_name(node));
of_node_put(np); of_node_put(np);
return 0; return 0;
} }
......
...@@ -240,12 +240,19 @@ static int rsnd_dmaen_start(struct rsnd_mod *mod, ...@@ -240,12 +240,19 @@ static int rsnd_dmaen_start(struct rsnd_mod *mod,
struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name, struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name,
struct rsnd_mod *mod, char *x) struct rsnd_mod *mod, char *x)
{ {
struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
struct device *dev = rsnd_priv_to_dev(priv);
struct dma_chan *chan = NULL; struct dma_chan *chan = NULL;
struct device_node *np; struct device_node *np;
int i = 0; int i = 0;
for_each_child_of_node(of_node, np) { for_each_child_of_node(of_node, np) {
i = rsnd_node_fixed_index(np, name, i); i = rsnd_node_fixed_index(dev, np, name, i);
if (i < 0) {
chan = NULL;
of_node_put(np);
break;
}
if (i == rsnd_mod_id_raw(mod) && (!chan)) if (i == rsnd_mod_id_raw(mod) && (!chan))
chan = of_dma_request_slave_channel(np, x); chan = of_dma_request_slave_channel(np, x);
......
...@@ -460,7 +460,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, ...@@ -460,7 +460,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name,
struct device_node *playback, struct device_node *playback,
struct device_node *capture); struct device_node *capture);
int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name); int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name);
int rsnd_node_fixed_index(struct device_node *node, char *name, int idx); int rsnd_node_fixed_index(struct device *dev, struct device_node *node, char *name, int idx);
int rsnd_channel_normalization(int chan); int rsnd_channel_normalization(int chan);
#define rsnd_runtime_channel_original(io) \ #define rsnd_runtime_channel_original(io) \
......
...@@ -676,7 +676,12 @@ int rsnd_src_probe(struct rsnd_priv *priv) ...@@ -676,7 +676,12 @@ int rsnd_src_probe(struct rsnd_priv *priv)
if (!of_device_is_available(np)) if (!of_device_is_available(np))
goto skip; goto skip;
i = rsnd_node_fixed_index(np, SRC_NAME, i); i = rsnd_node_fixed_index(dev, np, SRC_NAME, i);
if (i < 0) {
ret = -EINVAL;
of_node_put(np);
goto rsnd_src_probe_done;
}
src = rsnd_src_get(priv, i); src = rsnd_src_get(priv, i);
......
...@@ -1105,6 +1105,7 @@ void rsnd_parse_connect_ssi(struct rsnd_dai *rdai, ...@@ -1105,6 +1105,7 @@ void rsnd_parse_connect_ssi(struct rsnd_dai *rdai,
struct device_node *capture) struct device_node *capture)
{ {
struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
struct device *dev = rsnd_priv_to_dev(priv);
struct device_node *node; struct device_node *node;
struct device_node *np; struct device_node *np;
int i; int i;
...@@ -1117,7 +1118,11 @@ void rsnd_parse_connect_ssi(struct rsnd_dai *rdai, ...@@ -1117,7 +1118,11 @@ void rsnd_parse_connect_ssi(struct rsnd_dai *rdai,
for_each_child_of_node(node, np) { for_each_child_of_node(node, np) {
struct rsnd_mod *mod; struct rsnd_mod *mod;
i = rsnd_node_fixed_index(np, SSI_NAME, i); i = rsnd_node_fixed_index(dev, np, SSI_NAME, i);
if (i < 0) {
of_node_put(np);
break;
}
mod = rsnd_ssi_mod_get(priv, i); mod = rsnd_ssi_mod_get(priv, i);
...@@ -1182,7 +1187,12 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) ...@@ -1182,7 +1187,12 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
if (!of_device_is_available(np)) if (!of_device_is_available(np))
goto skip; goto skip;
i = rsnd_node_fixed_index(np, SSI_NAME, i); i = rsnd_node_fixed_index(dev, np, SSI_NAME, i);
if (i < 0) {
ret = -EINVAL;
of_node_put(np);
goto rsnd_ssi_probe_done;
}
ssi = rsnd_ssi_get(priv, i); ssi = rsnd_ssi_get(priv, i);
......
...@@ -462,6 +462,7 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai, ...@@ -462,6 +462,7 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai,
struct device_node *capture) struct device_node *capture)
{ {
struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai);
struct device *dev = rsnd_priv_to_dev(priv);
struct device_node *node = rsnd_ssiu_of_node(priv); struct device_node *node = rsnd_ssiu_of_node(priv);
struct rsnd_dai_stream *io_p = &rdai->playback; struct rsnd_dai_stream *io_p = &rdai->playback;
struct rsnd_dai_stream *io_c = &rdai->capture; struct rsnd_dai_stream *io_c = &rdai->capture;
...@@ -474,7 +475,11 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai, ...@@ -474,7 +475,11 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai,
for_each_child_of_node(node, np) { for_each_child_of_node(node, np) {
struct rsnd_mod *mod; struct rsnd_mod *mod;
i = rsnd_node_fixed_index(np, SSIU_NAME, i); i = rsnd_node_fixed_index(dev, np, SSIU_NAME, i);
if (i < 0) {
of_node_put(np);
break;
}
mod = rsnd_ssiu_mod_get(priv, i); mod = rsnd_ssiu_mod_get(priv, i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment