drivers: spi_mcux_dspi: Fix unlikely but possible division by zero

Documentation doesn't specify if this function may return 0, so add an
inexpensive check to account for this.

Jira: ZEP-2135
CID: 160954
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
Leandro Pereira 2017-05-22 14:21:27 -07:00 committed by Maureen Helm
commit 5315ee3122

View file

@ -77,6 +77,10 @@ static int spi_mcux_configure(struct device *dev, struct spi_config *spi_config)
word_size, spi_config->max_sys_freq);
clock_freq = CLOCK_GetFreq(config->clock_source);
if (!clock_freq) {
SYS_LOG_ERR("Got frequency of 0");
return -EINVAL;
}
DSPI_MasterInit(base, &master_config, clock_freq);
DSPI_MasterTransferCreateHandle(base, &data->handle,