summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/rt5514-spi.c
diff options
context:
space:
mode:
authoroder_chiou@realtek.com <oder_chiou@realtek.com>2017-07-31 08:47:42 +0300
committerMark Brown <broonie@kernel.org>2017-08-01 16:12:37 +0300
commit818010dac09183e99ff02e35836544b2e1d659f3 (patch)
treeaedfcd3ca05ce1cb6bbd7975a7867f0df807c7c9 /sound/soc/codecs/rt5514-spi.c
parentc2bf252536577db77c719f62a54cad2e4be5c4d7 (diff)
downloadlinux-818010dac09183e99ff02e35836544b2e1d659f3.tar.xz
ASoC: rt5514: Add the sanity checks of the buffer related address
The patch add the sanity checks of the buffer related address to make sure the addresses are valid. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt5514-spi.c')
-rw-r--r--sound/soc/codecs/rt5514-spi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 950d1ffdc06c..6f513cc4c56c 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -173,9 +173,14 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data)
rt5514_dsp->buf_rp = buf[0] | buf[1] << 8 | buf[2] << 16 |
buf[3] << 24;
+ if (rt5514_dsp->buf_rp % 8)
+ rt5514_dsp->buf_rp = (rt5514_dsp->buf_rp / 8) * 8;
+
rt5514_dsp->buf_size = rt5514_dsp->buf_limit - rt5514_dsp->buf_base;
- schedule_delayed_work(&rt5514_dsp->copy_work, 0);
+ if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit &&
+ rt5514_dsp->buf_rp && rt5514_dsp->buf_size)
+ schedule_delayed_work(&rt5514_dsp->copy_work, 0);
return IRQ_HANDLED;
}