ASoC: rsnd: adg: care clock-frequency size
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 6 Sep 2018 03:21:33 +0000 (03:21 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 6 Sep 2018 10:12:52 +0000 (11:12 +0100)
ADG has buffer over flow bug if DT has more than 3 clock-frequency.
This patch fixup this issue, and uses first 2 values.

clock-frequency = <x y>; /* this is OK */
clock-frequency = <x y z>; /* this is NG */

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/adg.c

index 3a3064dda57f329a96be5ef17b1dea8251f09f72..051f96405346b2f495c94ebc409656c98634a3c8 100644 (file)
@@ -462,6 +462,11 @@ static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
                goto rsnd_adg_get_clkout_end;
 
        req_size = prop->length / sizeof(u32);
+       if (req_size > REQ_SIZE) {
+               dev_err(dev,
+                       "too many clock-frequency, use top %d\n", REQ_SIZE);
+               req_size = REQ_SIZE;
+       }
 
        of_property_read_u32_array(np, "clock-frequency", req_rate, req_size);
        req_48kHz_rate = 0;