Skip to content

Commit 6618e7a

Browse files
morimotogregkh
authored andcommitted
ASoC: simple-card: fixup asoc_simple_probe() error handling
[ Upstream commit 41bae58 ] asoc_simple_probe() is used for both "DT probe" (A) and "platform probe" (B). It uses "goto err" when error case, but it is not needed for "platform probe" case (B). Thus it is using "return" directly there. static int asoc_simple_probe(...) { ^ if (...) { | ... (A) if (ret < 0) | goto err; v } else { ^ ... | if (ret < 0) (B) return -Exxx; v } ... ^ if (ret < 0) (C) goto err; v ... err: (D) simple_util_clean_reference(card); return ret; } Both case are using (C) part, and it calls (D) when err case. But (D) will do nothing for (B) case. Because of these behavior, current code itself is not wrong, but is confusable, and more, static analyzing tool will warning on (B) part (should use goto err). To avoid static analyzing tool warning, this patch uses "goto err" on (B) part. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Kuninori Morimoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4a61839 commit 6618e7a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sound/soc/generic/simple-card.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,12 @@ static int asoc_simple_probe(struct platform_device *pdev)
678678
struct snd_soc_dai_link *dai_link = priv->dai_link;
679679
struct simple_dai_props *dai_props = priv->dai_props;
680680

681+
ret = -EINVAL;
682+
681683
cinfo = dev->platform_data;
682684
if (!cinfo) {
683685
dev_err(dev, "no info for asoc-simple-card\n");
684-
return -EINVAL;
686+
goto err;
685687
}
686688

687689
if (!cinfo->name ||
@@ -690,7 +692,7 @@ static int asoc_simple_probe(struct platform_device *pdev)
690692
!cinfo->platform ||
691693
!cinfo->cpu_dai.name) {
692694
dev_err(dev, "insufficient asoc_simple_card_info settings\n");
693-
return -EINVAL;
695+
goto err;
694696
}
695697

696698
cpus = dai_link->cpus;

0 commit comments

Comments
 (0)