Skip to content

Commit 8a2278b

Browse files
Nicolin Chenbroonie
authored andcommitted
ASoC: fsl_esai: Add freq check in set_dai_sysclk()
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>
1 parent 728815e commit 8a2278b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎sound/soc/fsl/fsl_esai.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
226226
unsigned long clk_rate;
227227
int ret;
228228

229+
if (freq == 0) {
230+
dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n",
231+
in ? "in" : "out", tx ? 'T' : 'R');
232+
return -EINVAL;
233+
}
234+
229235
/* Bypass divider settings if the requirement doesn't change */
230236
if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx])
231237
return 0;

0 commit comments

Comments
 (0)