espi: mchp_xec_v2: Fix possible buffer overflow

Check the packet lenght in flash_write operation beforeSigned-off-by
copying it to an internal buffer.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2023-08-06 23:30:29 -07:00 committed by Martí Bolívar
commit c5bb002f77

View file

@ -524,6 +524,11 @@ static int espi_xec_flash_write(const struct device *dev,
LOG_DBG("%s", __func__);
if (sizeof(target_mem) < pckt->len) {
LOG_ERR("Packet length is too big");
return -ENOMEM;
}
if (!(regs->FCSTS & MCHP_ESPI_FC_STS_CHAN_EN)) {
LOG_ERR("Flash channel is disabled");
return -EIO;