summaryrefslogtreecommitdiff
path: root/sound/soc/generic
diff options
context:
space:
mode:
authorAmeer Hamza <amhamza.mgc@gmail.com>2021-12-05 23:42:00 +0300
committerMark Brown <broonie@kernel.org>2021-12-06 16:49:26 +0300
commitc686316ec1210d43653c91e104c1e4cd0156dc89 (patch)
tree434c791e2296c36139ac65ade1836444633fa6ea /sound/soc/generic
parente733ab7e3e5dc1bf7d34e050e839fc902ce7ff98 (diff)
downloadlinux-c686316ec1210d43653c91e104c1e4cd0156dc89.tar.xz
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>
Diffstat (limited to 'sound/soc/generic')
-rw-r--r--sound/soc/generic/test-component.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sound/soc/generic/test-component.c b/sound/soc/generic/test-component.c
index 85385a771d80..8fc97d3ff011 100644
--- a/sound/soc/generic/test-component.c
+++ b/sound/soc/generic/test-component.c
@@ -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");