From 3dfb48533484b8ba6ba1b1c1a39fcfee9491989c Mon Sep 17 00:00:00 2001 From: Felix Held Date: Wed, 28 Sep 2022 18:00:39 +0200 Subject: [PATCH] util/amdfwtool/data_parse: fix PMU subprogram/instance ID handling The parsing of the PMU binary subprogram and instance numbers only worked correctly for the cases where the ID in the name in the fw.cfg file was between 0 and 9, but returned wrong results if it was between a and f. Switch to using strtol with a base of 16 instead of subtracting the char '0' from the char in the filename in find_register_fw_filename_bios_dir to fix this. Signed-off-by: Felix Held Change-Id: Ic5fd41daf9f26d11c1f86375387c1d7beac04124 Reviewed-on: https://review.coreboot.org/c/coreboot/+/67927 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier Reviewed-by: Arthur Heymans --- util/amdfwtool/data_parse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c index 14c1567321..424a68a90c 100644 --- a/util/amdfwtool/data_parse.c +++ b/util/amdfwtool/data_parse.c @@ -375,13 +375,13 @@ static uint8_t find_register_fw_filename_bios_dir(char *fw_name, char *filename, if (strncmp(fw_name, PMUI_STR_BASE, PMU_STR_BASE_LEN) == 0) { assert(strlen(fw_name) == PMU_STR_ALL_LEN); fw_type = AMD_BIOS_PMUI; - subprog = fw_name[PMU_STR_SUB_INDEX] - '0'; - instance = fw_name[PMU_STR_INS_INDEX] - '0'; + subprog = strtol(&fw_name[PMU_STR_SUB_INDEX], NULL, 16); + instance = strtol(&fw_name[PMU_STR_INS_INDEX], NULL, 16); } else if (strncmp(fw_name, PMUD_STR_BASE, PMU_STR_BASE_LEN) == 0) { assert(strlen(fw_name) == PMU_STR_ALL_LEN); fw_type = AMD_BIOS_PMUD; - subprog = fw_name[PMU_STR_SUB_INDEX] - '0'; - instance = fw_name[PMU_STR_INS_INDEX] - '0'; + subprog = strtol(&fw_name[PMU_STR_SUB_INDEX], NULL, 16); + instance = strtol(&fw_name[PMU_STR_INS_INDEX], NULL, 16); } else if (strcmp(fw_name, "RTM_PUBKEY_FILE") == 0) { fw_type = AMD_BIOS_RTM_PUBKEY; subprog = 0;