Skip to content

Commit f7a6021

Browse files
JiangJiasbroonie
authored andcommitted
ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name
If the device does not exist, of_get_child_by_name() will return NULL pointer. And devm_snd_soc_register_component() does not check it. Also, I have noticed that cpcap_codec_driver has not been used yet. Therefore, it should be better to check it in order to avoid the future dereference of the NULL pointer. Fixes: f6cdf2d ("ASoC: cpcap: new codec") Signed-off-by: Jiasheng Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a64067f commit f7a6021

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/soc/codecs/cpcap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,8 @@ static int cpcap_codec_probe(struct platform_device *pdev)
16671667
{
16681668
struct device_node *codec_node =
16691669
of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec");
1670+
if (!codec_node)
1671+
return -ENODEV;
16701672

16711673
pdev->dev.of_node = codec_node;
16721674

0 commit comments

Comments
 (0)