]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: fsl_esai: Add freq check in set_dai_sysclk()
authorNicolin Chen <nicoleotsuka@gmail.com>
Mon, 9 Apr 2018 00:33:54 +0000 (17:33 -0700)
committerMark Brown <broonie@kernel.org>
Mon, 16 Apr 2018 12:04:40 +0000 (13:04 +0100)
The freq parameter indicates the physical frequency of an actual
input clock or a desired frequency of an output clock for HCKT/R.
It should never be passed 0. This might cause Division-by-zero.

So this patch adds a check to fix it.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_esai.c

index da8fd98c7f51c2a1ee3116a00d17d8820bb3582d..d79e99ef31ad1a68721b40b64b3d35af347dbbb7 100644 (file)
@@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
        unsigned long clk_rate;
        int ret;
 
+       if (freq == 0) {
+               dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n",
+                       in ? "in" : "out", tx ? 'T' : 'R');
+               return -EINVAL;
+       }
+
        /* Bypass divider settings if the requirement doesn't change */
        if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx])
                return 0;