diff options
author | Nico Huber <nico.h@gmx.de> | 2021-05-14 00:39:24 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2021-06-26 15:58:44 +0000 |
commit | e03a5f7d5daa0fb00c32081c0e1e86781d500686 (patch) | |
tree | 1975a1ddfbd8442d455968a6d5e97ae41443fb6a /libflashrom.c | |
parent | 73ae47ecc2a491def93e421be1094001ece7407b (diff) | |
download | flashrom-e03a5f7d5daa0fb00c32081c0e1e86781d500686.tar.gz flashrom-e03a5f7d5daa0fb00c32081c0e1e86781d500686.tar.bz2 flashrom-e03a5f7d5daa0fb00c32081c0e1e86781d500686.zip |
libflashrom: Avoid using the global layout
We used to borrow the global layout from the CLI here. Create
a dynamically allocated one instead that doesn't need special
treatment.
Change-Id: Ic48c9e73a3d00782f638f6ff41b620910b24ab6f
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54284
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'libflashrom.c')
-rw-r--r-- | libflashrom.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libflashrom.c b/libflashrom.c index d0f94a9e3..1ecf650f6 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -502,15 +502,17 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout, int i; char name[FMAP_STRLEN + 1]; const struct fmap_area *area; - struct flashrom_layout *l = get_global_layout(); + struct flashrom_layout *l; - if (!fmap || !l) + if (!fmap || flashrom_layout_new(&l)) return 1; for (i = 0, area = fmap->areas; i < fmap->nareas; i++, area++) { snprintf(name, sizeof(name), "%s", area->name); - if (flashrom_layout_add_region(l, area->offset, area->offset + area->size - 1, name)) + if (flashrom_layout_add_region(l, area->offset, area->offset + area->size - 1, name)) { + flashrom_layout_release(l); return 1; + } } *layout = l; |