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:
parent
789721e9cc
commit
5315ee3122
1 changed files with 4 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue