diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-10-23 06:47:15 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-10-24 04:37:59 +0000 |
commit | 124fa1da4184220ed061ce6fc66683c5df6578c7 (patch) | |
tree | 946c7daadad8a7dfcc75fc20c7348658b5b03203 | |
parent | 0e6f491742425261feed32eec143146747c07c7c (diff) | |
download | vboot-124fa1da4184220ed061ce6fc66683c5df6578c7.tar.gz |
futility: Preserve programmer in free_firmware_image
The `programmer` cannot be decided in `load_firmware_image` and is always
specified (and managed) by an outer context, and should be preserved
even when we call `free_firmware_image`.
This helps reloading or removing loaded images at runtime.
BUG=chromium:875551
TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None
Change-Id: I22f698d4a7118197379e11556b18f70ecd023ca2
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1295209
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/1296947
-rw-r--r-- | futility/updater.c | 7 | ||||
-rw-r--r-- | futility/updater_quirks.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/futility/updater.c b/futility/updater.c index f4e793b3..4ddf53db 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -648,12 +648,19 @@ int load_system_firmware(struct updater_config *cfg, */ void free_firmware_image(struct firmware_image *image) { + /* + * The programmer is not allocated by load_firmware_image and must be + * preserved explicitly. + */ + const char *programmer = image->programmer; + free(image->data); free(image->file_name); free(image->ro_version); free(image->rw_version_a); free(image->rw_version_b); memset(image, 0, sizeof(*image)); + image->programmer = programmer; } /* diff --git a/futility/updater_quirks.c b/futility/updater_quirks.c index 8c924a37..5480d3c6 100644 --- a/futility/updater_quirks.c +++ b/futility/updater_quirks.c @@ -53,11 +53,10 @@ static int write_image(const char *file_path, struct firmware_image *image) } /* Preserves meta data and reload image contents from given file path. */ -static int reload_firmware_image(const char *file_path, struct firmware_image *image) +static int reload_firmware_image(const char *file_path, + struct firmware_image *image) { - const char *programmer = image->programmer; free_firmware_image(image); - image->programmer = programmer; return load_firmware_image(image, file_path, NULL); } |