Commit e1b790a8 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Mark Brown

SoC: mxs-saif: check validity of ids in mxs_saif_probe()

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: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1001354c
...@@ -735,6 +735,11 @@ static int mxs_saif_probe(struct platform_device *pdev) ...@@ -735,6 +735,11 @@ static int mxs_saif_probe(struct platform_device *pdev)
else else
saif->id = ret; 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 * If there is no "fsl,saif-master" phandle, it's a saif
* master. Otherwise, it's a slave and its phandle points * master. Otherwise, it's a slave and its phandle points
...@@ -749,11 +754,11 @@ static int mxs_saif_probe(struct platform_device *pdev) ...@@ -749,11 +754,11 @@ static int mxs_saif_probe(struct platform_device *pdev)
return ret; return ret;
else else
saif->master_id = ret; saif->master_id = ret;
}
if (saif->master_id >= ARRAY_SIZE(mxs_saif)) { if (saif->master_id >= ARRAY_SIZE(mxs_saif)) {
dev_err(&pdev->dev, "get wrong master id\n"); dev_err(&pdev->dev, "get wrong master id\n");
return -EINVAL; return -EINVAL;
}
} }
mxs_saif[saif->id] = saif; mxs_saif[saif->id] = saif;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment