Skip to content

Commit c686316

Browse files
amer-hamzabroonie
authored andcommitted
ASoC: test-component: fix null pointer dereference.
Dereferncing of_id pointer will result in exception in current implementation since of_match_device() will assign it to NULL. Adding NULL check for protection. Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com> Link: https://lore.kernel.org/r/20211205204200.7852-1-amhamza.mgc@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e733ab7 commit c686316

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

sound/soc/generic/test-component.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,16 @@ static int test_driver_probe(struct platform_device *pdev)
532532
struct device_node *node = dev->of_node;
533533
struct device_node *ep;
534534
const struct of_device_id *of_id = of_match_device(test_of_match, &pdev->dev);
535-
const struct test_adata *adata = of_id->data;
535+
const struct test_adata *adata;
536536
struct snd_soc_component_driver *cdriv;
537537
struct snd_soc_dai_driver *ddriv;
538538
struct test_dai_name *dname;
539539
struct test_priv *priv;
540540
int num, ret, i;
541541

542+
if (!of_id)
543+
return -EINVAL;
544+
adata = of_id->data;
542545
num = of_graph_get_endpoint_count(node);
543546
if (!num) {
544547
dev_err(dev, "no port exits\n");

0 commit comments

Comments
 (0)