Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SoC: mxs-saif: check validity of ids in mxs_saif_probe()
@ 2016-10-14 21:53 Alexey Khoroshilov
  2016-10-26 10:15 ` Applied "SoC: mxs-saif: check validity of ids in mxs_saif_probe()" to the asoc tree Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2016-10-14 21:53 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: ldv-project, alsa-devel, Mans Rullgard, linux-kernel,
	Takashi Iwai, Alexey Khoroshilov

There is a check for validity of one of ids in mxs_saif_probe(),
while array dereferece is made by the other id.

The patch adds the check for the second saif id.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 sound/soc/mxs/mxs-saif.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index 13631003cb7c..a002ab892772 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -735,6 +735,11 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	else
 		saif->id = ret;
 
+	if (saif->id >= ARRAY_SIZE(mxs_saif)) {
+		dev_err(&pdev->dev, "get wrong saif id\n");
+		return -EINVAL;
+	}
+
 	/*
 	 * If there is no "fsl,saif-master" phandle, it's a saif
 	 * master.  Otherwise, it's a slave and its phandle points
@@ -749,11 +754,11 @@ static int mxs_saif_probe(struct platform_device *pdev)
 			return ret;
 		else
 			saif->master_id = ret;
-	}
 
-	if (saif->master_id >= ARRAY_SIZE(mxs_saif)) {
-		dev_err(&pdev->dev, "get wrong master id\n");
-		return -EINVAL;
+		if (saif->master_id >= ARRAY_SIZE(mxs_saif)) {
+			dev_err(&pdev->dev, "get wrong master id\n");
+			return -EINVAL;
+		}
 	}
 
 	mxs_saif[saif->id] = saif;
-- 
2.7.4

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

end of thread, other threads:[~2016-10-26 10:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-14 21:53 [PATCH] SoC: mxs-saif: check validity of ids in mxs_saif_probe() Alexey Khoroshilov
2016-10-26 10:15 ` Applied "SoC: mxs-saif: check validity of ids in mxs_saif_probe()" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox