subsys/storage/flash_map: detect missing flash device

If the flash device is not configured, return an error rather than
dereferencing a null device pointer.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
Peter A. Bigot 2019-07-20 16:56:01 -05:00 committed by Kumar Gala
commit e3ba01ec76
2 changed files with 6 additions and 1 deletions

View file

@ -139,6 +139,9 @@ flash_page_cb cb, struct layout_data *cb_data)
cb_data->status = 0;
flash_dev = device_get_binding(fa->fa_dev_name);
if (flash_dev == NULL) {
return -ENODEV;
}
flash_page_foreach(flash_dev, cb, cb_data);