@@ -916,6 +916,11 @@ static int i2s_esp32_configure_dir(const struct device *dev, enum i2s_dir dir,
916916 return 0 ;
917917 }
918918
919+ if (i2s_cfg -> mem_slab == NULL ) {
920+ LOG_ERR ("Memory slab is NULL" );
921+ return - EINVAL ;
922+ }
923+
919924 data_format = i2s_cfg -> format & I2S_FMT_DATA_FORMAT_MASK ;
920925
921926 if (data_format != I2S_FMT_DATA_FORMAT_I2S &&
@@ -925,6 +930,11 @@ static int i2s_esp32_configure_dir(const struct device *dev, enum i2s_dir dir,
925930 return - EINVAL ;
926931 }
927932
933+ if (data_format == I2S_FMT_DATA_FORMAT_I2S && i2s_cfg -> format & I2S_FMT_DATA_ORDER_LSB ) {
934+ LOG_ERR ("Invalid format: %u" , (unsigned int )i2s_cfg -> format );
935+ return - EINVAL ;
936+ }
937+
928938 if (i2s_cfg -> word_size != 8 && i2s_cfg -> word_size != 16 && i2s_cfg -> word_size != 24 &&
929939 i2s_cfg -> word_size != 32 ) {
930940 LOG_ERR ("Word size not supported: %d" , (int )i2s_cfg -> word_size );
@@ -980,8 +990,10 @@ static int i2s_esp32_configure_dir(const struct device *dev, enum i2s_dir dir,
980990#endif /* SOC_I2S_HW_VERSION_2 */
981991 } else {
982992 LOG_ERR ("Unsupported data format: %u" , (unsigned int )data_format );
993+ return - EINVAL ;
983994 }
984995 }
996+
985997 slot_cfg .std .ws_width = slot_cfg .slot_bit_width ;
986998 slot_cfg .std .slot_mask = I2S_STD_SLOT_BOTH ;
987999#if SOC_I2S_HW_VERSION_1
@@ -1517,16 +1529,16 @@ static DEVICE_API(i2s, i2s_esp32_driver_api) = {
15171529 I2S_ESP32_STREAM_DECL_DMA_DESC(index, tx); \
15181530 I2S_ESP32_STREAM_DECL(index, tx); \
15191531 \
1520- static struct i2s_esp32_data i2s_esp32_data_##index = { \
1521- .clk_info = {0}}; \
1532+ static struct i2s_esp32_data i2s_esp32_data_##index = {.clk_info = {0}}; \
15221533 \
15231534 static const struct i2s_esp32_cfg i2s_esp32_config_##index = { \
15241535 .unit = DT_PROP(DT_DRV_INST(index), unit), \
15251536 .hal = {.dev = (i2s_dev_t *)DT_INST_REG_ADDR(index)}, \
15261537 .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
15271538 .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(index)), \
15281539 .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(index, offset), \
1529- I2S_ESP32_STREAM_INIT(index, rx), I2S_ESP32_STREAM_INIT(index, tx)}; \
1540+ I2S_ESP32_STREAM_INIT(index, rx), \
1541+ I2S_ESP32_STREAM_INIT(index, tx)}; \
15301542 \
15311543 DEVICE_DT_INST_DEFINE(index, &i2s_esp32_initialize, NULL, &i2s_esp32_data_##index, \
15321544 &i2s_esp32_config_##index, POST_KERNEL, CONFIG_I2S_INIT_PRIORITY, \
0 commit comments