flashparams: Fix a null-pointer dereference crash

Fix a potential crash caused by calling erase_sector with a null
sector_descriptor (current_sector == 0).

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen
2021-04-13 09:00:18 +03:00
committed by David Sidrane
parent 58b40fbbb9
commit b99e597a73
+5 -3
View File
@@ -875,11 +875,13 @@ parameter_flashfs_write(flash_file_token_t token, uint8_t *buffer, size_t buf_si
}
pf = (flash_entry_header_t *) current_sector->address;
if (!blank_check(pf, total_size)) {
rv = erase_sector(current_sector, pf);
}
}
if (!blank_check(pf, total_size)) {
rv = erase_sector(current_sector, pf);
}
}
flash_entry_header_t *pn = (flash_entry_header_t *)(buffer - sizeof(flash_entry_header_t));