]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ASoC: test-component: fix null pointer dereference.
authorAmeer Hamza <amhamza.mgc@gmail.com>
Sun, 5 Dec 2021 20:42:00 +0000 (01:42 +0500)
committerMark Brown <broonie@kernel.org>
Mon, 6 Dec 2021 13:49:26 +0000 (13:49 +0000)
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>
sound/soc/generic/test-component.c

index 85385a771d80716cc1f69d01a8d11727781e1009..8fc97d3ff01105fb1f802c364b5cd39964f8a294 100644 (file)
@@ -532,13 +532,16 @@ static int test_driver_probe(struct platform_device *pdev)
        struct device_node *node = dev->of_node;
        struct device_node *ep;
        const struct of_device_id *of_id = of_match_device(test_of_match, &pdev->dev);
-       const struct test_adata *adata = of_id->data;
+       const struct test_adata *adata;
        struct snd_soc_component_driver *cdriv;
        struct snd_soc_dai_driver *ddriv;
        struct test_dai_name *dname;
        struct test_priv *priv;
        int num, ret, i;
 
+       if (!of_id)
+               return -EINVAL;
+       adata = of_id->data;
        num = of_graph_get_endpoint_count(node);
        if (!num) {
                dev_err(dev, "no port exits\n");