ASoC: rt5514: Add the sanity checks of the buffer related address
authoroder_chiou@realtek.com <oder_chiou@realtek.com>
Mon, 31 Jul 2017 05:47:42 +0000 (13:47 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 1 Aug 2017 13:12:37 +0000 (14:12 +0100)
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>
sound/soc/codecs/rt5514-spi.c

index 950d1ffdc06c5674648899a9faeec56f7d7f237b..6f513cc4c56c043b6d365f534fad861bb3334614 100644 (file)
@@ -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;
 }