From 7e8d17a8bd6e8239375666920b1824c4d24d4a01 Mon Sep 17 00:00:00 2001 From: Nikolai Artemiev Date: Tue, 20 Sep 2022 15:45:34 +1000 Subject: cli_classic.c: Add error messages for invalid --wp-region use Print errors if --wp-region is used without a layout file or the layout file doesn't contain the region. BUG=b:247055486 TEST=builds Change-Id: Ie606ba7f8a423405099679ca62169c395d994b5d Signed-off-by: Nikolai Artemiev Reviewed-on: https://review.coreboot.org/c/flashrom/+/67725 Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer --- cli_classic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cli_classic.c') diff --git a/cli_classic.c b/cli_classic.c index bac31d1c..3de00206 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -1110,9 +1110,17 @@ int main(int argc, char *argv[]) if (any_wp_op) { if (set_wp_region && wp_region) { + if (!layout) { + msg_gerr("Error: A flash layout must be specified to use --wp-region.\n"); + ret = 1; + goto out_release; + } + ret = flashrom_layout_get_region_range(layout, wp_region, &wp_start, &wp_len); - if (ret) + if (ret) { + msg_gerr("Error: Region %s not found in flash layout.\n", wp_region); goto out_release; + } set_wp_range = true; } ret = wp_cli( -- cgit v1.2.3