diff options
author | Alexey Khoroshilov <khoroshilov@ispras.ru> | 2016-10-15 00:53:36 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-10-26 11:14:32 +0100 |
commit | e1b790a8720192e1cfdd46a9b20d0f56de99c73d (patch) | |
tree | 0ae7b59665a7f6ac76ec2e5d5619839fccff6782 /sound/soc/mxs | |
parent | 1001354ca34179f3db924eb66672442a173147dc (diff) | |
download | linux-e1b790a8720192e1cfdd46a9b20d0f56de99c73d.tar.gz linux-e1b790a8720192e1cfdd46a9b20d0f56de99c73d.tar.bz2 linux-e1b790a8720192e1cfdd46a9b20d0f56de99c73d.zip |
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: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/mxs')
-rw-r--r-- | sound/soc/mxs/mxs-saif.c | 13 |
1 files 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; |