diff options
author | Tuo Li <tuoli96@outlook.com> | 2020-09-07 16:09:37 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-09-11 17:52:20 +0300 |
commit | 375e2c352582442783178e6a33c279d6bc9354a2 (patch) | |
tree | b44209063ac78a655516f3f3e9aeab8b193642b7 /sound | |
parent | 2a4b91a26403fa3e7b07271700c3ca7103664bba (diff) | |
download | linux-375e2c352582442783178e6a33c279d6bc9354a2.tar.xz |
ALSA: rockchip_i2s: fix a possible divide-by-zero bug in rockchip_i2s_hw_params()
The variable bclk_rate is checked in:
if (bclk_rate && mclk_rate % bclk_rate)
This indicates that bclk_rate can be zero.
If so, a divide-by-zero bug will occur:
div_bclk = mclk_rate / bclk_rate;
To fix this possible bug, the function returns -EINVAL when bclk_rate is
zero.
Signed-off-by: Tuo Li <tuoli96@outlook.com>
Link: https://lore.kernel.org/r/TY2PR04MB4029799E60A5BCAAD5B7B5BBB8280@TY2PR04MB4029.apcprd04.prod.outlook.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/rockchip/rockchip_i2s.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index d1438753edb4..593299675b8c 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -279,7 +279,7 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, if (i2s->is_master_mode) { mclk_rate = clk_get_rate(i2s->mclk); bclk_rate = 2 * 32 * params_rate(params); - if (bclk_rate && mclk_rate % bclk_rate) + if (bclk_rate == 0 || mclk_rate % bclk_rate) return -EINVAL; div_bclk = mclk_rate / bclk_rate; |