drm/bridge: sii902x: re-order conditions to prevent out of bounds read

This should check that "i" is within bounds before checking reading from
the array.

Fixes: ff5781634c ("drm/bridge: sii902x: Implement HDMI audio support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190607072704.GA25229@mwanda
This commit is contained in:
Dan Carpenter 2019-06-07 10:27:04 +03:00 committed by Andrzej Hajda
parent 35ab6cfbf2
commit 955f03a7d0

View File

@ -599,8 +599,8 @@ static int sii902x_audio_hw_params(struct device *dev, void *data,
if (ret)
goto out;
for (i = 0; sii902x->audio.i2s_fifo_sequence[i] &&
i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence); i++)
for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence) &&
sii902x->audio.i2s_fifo_sequence[i]; i++)
regmap_write(sii902x->regmap,
SII902X_TPI_I2S_ENABLE_MAPPING_REG,
sii902x->audio.i2s_fifo_sequence[i]);