espi: mchp_xec: Fix possible buffer overflow
Check the packet lenght in flash_write operation before copying it to an internal buffer. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
34102e496e
commit
4102179f3f
1 changed files with 5 additions and 0 deletions
|
@ -647,6 +647,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 (!(ESPI_FC_REGS->STS & MCHP_ESPI_FC_STS_CHAN_EN)) {
|
||||
LOG_ERR("Flash channel is disabled");
|
||||
return -EIO;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue