ASoC: simple-card: Dereference pointer for memcpy sizeof in asoc_simple_card_probe
PATCH 1/1 ASoC: simple-card: Dereference pointer for memcpy sizeof in asoc_simple_card_probe
Clang warns:
sound/soc/generic/simple-card.c:462:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'struct asoc_simple_dai *' as the source; expected 'struct asoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]
sizeof(priv->dai_props->cpu_dai));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~sound/soc/generic/simple-card.c:464:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'struct asoc_simple_dai *' as the source; expected 'struct asoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]
sizeof(priv->dai_props->codec_dai));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2 warnings generated.
Commit 4fb7f4df49d3 ("ASoC: simple-card: use cpu/codec pointer on simple_dai_props") updated {cpu,codec}_dai to be pointers in struct simple_dai_props but didn't update these locations to dereference the pointers to get the proper size of their contents.
--- sound/soc/generic/simple-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/generic/simple-card.c +2 -2
@@ -459,9 +459,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) dai_link->dai_fmt = cinfo->daifmt; dai_link->init = asoc_simple_card_dai_init;memcpy (&priv->dai_props->cpu_dai, &cinfo->cpu_dai, -sizeof (priv->dai_props->cpu_dai)); +sizeof (*priv->dai_props->cpu_dai));memcpy (&priv->dai_props->codec_dai, &cinfo->codec_dai, -sizeof (priv->dai_props->codec_dai)); +sizeof (*priv->dai_props->codec_dai)); }snd_soc_card_set_drvdata (card, priv);
Signature · 1 line
2.20.0
Kuninori Morimoto
maintainerHi Nathan
Quoted 29 lines
sound/soc/generic/simple-card.c:462:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'structasoc_simple_dai*' as the source; expected 'structasoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]sizeof(priv->dai_props->cpu_dai)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/soc/generic/simple-card.c:464:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'structasoc_simple_dai*' as the source; expected 'structasoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]sizeof(priv->dai_props->codec_dai)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2 warnings generated.
Commit
4fb7f4df49d3("ASoC: simple-card: use cpu/codec pointer onsimple_dai_props") updated {cpu,codec}_dai to be pointers in structsimple_dai_propsbut didn't update these locations to dereference the pointers to get the proper size of their contents.Signed-off-by Nathan Chancellor <[email protected]>--- sound/soc/generic/simple-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/soc/generic/simple-card.c +0
-0
sound/soc/generic/simple-card.c static int asoc_simple_card_probe(struct platform_device *pdev) · line 465
Quoted 9 lines
sound/soc/generic/simple-card.c +2
-2@@ -459,9 +459,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) dai_link->dai_fmt = cinfo->daifmt; dai_link->init = asoc_simple_card_dai_init;memcpy (&priv->dai_props->cpu_dai, &cinfo->cpu_dai, -sizeof (priv->dai_props->cpu_dai)); +sizeof (*priv->dai_props->cpu_dai));memcpy (&priv->dai_props->codec_dai, &cinfo->codec_dai, -sizeof (priv->dai_props->codec_dai)); +sizeof (*priv->dai_props->codec_dai)); }
Ahh.. yes, simple-card is supporting non DT case, too. Thank you for your patch.
But, I think "&priv->dai_props->codec_dai" need to fix, too. And it needs to point cpu_dai/codec_dai.
Thank you for pointing it. I will fixup and post with your name.
Best regards
---
Kuninori Morimoto
Quoted 48 lines · Kuninori Morimoto
Hi Nathan
Quoted 29 lines
sound/soc/generic/simple-card.c:462:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'structasoc_simple_dai*' as the source; expected 'structasoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]sizeof(priv->dai_props->cpu_dai)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/soc/generic/simple-card.c:464:6: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'structasoc_simple_dai*' as the source; expected 'structasoc_simple_dai' or an explicit length [-Wsizeof-pointer-memaccess]sizeof(priv->dai_props->codec_dai)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2 warnings generated.
Commit
4fb7f4df49d3("ASoC: simple-card: use cpu/codec pointer onsimple_dai_props") updated {cpu,codec}_dai to be pointers in structsimple_dai_propsbut didn't update these locations to dereference the pointers to get the proper size of their contents.Signed-off-by Nathan Chancellor <[email protected]>--- sound/soc/generic/simple-card.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)sound/soc/generic/simple-card.c +0
-0sound/soc/generic/simple-card.c static int asoc_simple_card_probe(struct platform_device *pdev) · line 465
Quoted 9 lines
sound/soc/generic/simple-card.c +2
-2@@ -459,9 +459,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) dai_link->dai_fmt = cinfo->daifmt; dai_link->init = asoc_simple_card_dai_init;memcpy (&priv->dai_props->cpu_dai, &cinfo->cpu_dai, -sizeof (priv->dai_props->cpu_dai)); +sizeof (*priv->dai_props->cpu_dai));memcpy (&priv->dai_props->codec_dai, &cinfo->codec_dai, -sizeof (priv->dai_props->codec_dai)); +sizeof (*priv->dai_props->codec_dai)); }Ahh.. yes, simple-card is supporting non DT case, too. Thank you for your patch.
But, I think "&priv->dai_props->codec_dai" need to fix, too. And it needs to point cpu_dai/codec_dai.
Thank you for pointing it. I will fixup and post with your name.
Quoted 3 lines
Best regards
---
Kuninori Morimoto
Sure, whatever you think is best, thank you for the quick response!
Nathan