mb/google/brya/var/{kano,osiris,taeko}: Add null pointer check

Without part no. in CBI, mainboard_get_dram_part_num returns null.
To prevent passing this null pointer to strcmp and avoid unexpected
behavior, proper handling is necessary.

BUG=none
TEST=emerge-brya coreboot

Change-Id: I47e42376c6b1347c56afaec218aed63c5469f0aa
Signed-off-by: Wisley Chen <wisley.chen@quanta.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/77646
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Reviewed-by: David Wu <david_wu@quanta.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Wisley Chen 2023-09-05 13:12:10 +08:00 committed by Felix Held
parent d99fac1949
commit 15cb0d5527
3 changed files with 18 additions and 15 deletions

View File

@ -136,10 +136,11 @@ const struct mb_cfg *variant_memory_params(void)
const char *hynix_mem1 = "H54G46CYRBX267"; const char *hynix_mem1 = "H54G46CYRBX267";
const char *hynix_mem2 = "H54G56CYRBX247"; const char *hynix_mem2 = "H54G56CYRBX247";
if (!strcmp(part_num, hynix_mem1) || !strcmp(part_num, hynix_mem2)) { if (part_num) {
printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix memory\n"); if (!strcmp(part_num, hynix_mem1) || !strcmp(part_num, hynix_mem2)) {
return &hynix_memcfg; printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix memory\n");
} else { return &hynix_memcfg;
return &kano_memcfg; }
} }
return &kano_memcfg;
} }

View File

@ -136,10 +136,11 @@ const struct mb_cfg *variant_memory_params(void)
const char *hynix_mem1 = "H54G46CYRBX267"; const char *hynix_mem1 = "H54G46CYRBX267";
const char *hynix_mem2 = "H54G56CYRBX247"; const char *hynix_mem2 = "H54G56CYRBX247";
if (!strcmp(part_num, hynix_mem1) || !strcmp(part_num, hynix_mem2)) { if (part_num) {
printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix memory\n"); if (!strcmp(part_num, hynix_mem1) || !strcmp(part_num, hynix_mem2)) {
return &hynix_memcfg; printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix memory\n");
} else { return &hynix_memcfg;
return &osiris_memcfg; }
} }
return &osiris_memcfg;
} }

View File

@ -135,12 +135,13 @@ static const struct mb_cfg hynix_memconfig = {
const struct mb_cfg *variant_memory_params(void) const struct mb_cfg *variant_memory_params(void)
{ {
const char *dram_part_num = mainboard_get_dram_part_num(); const char *dram_part_num = mainboard_get_dram_part_num();
if (strcmp(dram_part_num, "H54G46CYRBX267N") == 0) { if (dram_part_num) {
printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix DRAM part\n"); if (strcmp(dram_part_num, "H54G46CYRBX267N") == 0) {
return &hynix_memconfig; printk(BIOS_INFO, "Enable cs_pi_start_high_in_ect for Hynix DRAM part\n");
} else { return &hynix_memconfig;
return &baseboard_memcfg; }
} }
return &baseboard_memcfg;
} }
int variant_memory_sku(void) int variant_memory_sku(void)