alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: test-component: fix null pointer dereference.
@ 2021-12-05 20:42 Ameer Hamza
  2021-12-05 22:40 ` Kuninori Morimoto
  2021-12-06 18:00 ` Mark Brown
  0 siblings, 2 replies; 15+ messages in thread
From: Ameer Hamza @ 2021-12-05 20:42 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx, alsa-devel
  Cc: amhamza.mgc, linux-kernel

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>
---
 sound/soc/generic/test-component.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-12-09 13:46 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-05 20:42 [PATCH] ASoC: test-component: fix null pointer dereference Ameer Hamza
2021-12-05 22:40 ` Kuninori Morimoto
2021-12-06  9:29   ` Ameer Hamza
2021-12-06 23:19     ` Kuninori Morimoto
2021-12-07  8:15       ` Ameer Hamza
2021-12-07 12:51         ` Mark Brown
2021-12-07 14:23           ` [PATCH v2] " Ameer Hamza
2021-12-08  0:05             ` Kuninori Morimoto
2021-12-08 12:05               ` Ameer Hamza
2021-12-08 12:36                 ` [PATCH] ASoC: test-component: replace of_match_device() to of_device_get_match_data() Ameer Hamza
2021-12-08 12:40                   ` Ameer Hamza
2021-12-08 22:40                   ` Kuninori Morimoto
2021-12-09 13:45             ` [PATCH v2] ASoC: test-component: fix null pointer dereference Mark Brown
2021-12-07 23:53           ` [PATCH] " Kuninori Morimoto
2021-12-06 18:00 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).