From 7e2625587d11209bdecbeffda3267b2336477b78 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Thu, 23 Jan 2020 10:32:33 +1100 Subject: x86/acpi_device: Allow acpi_device_add_power_res params as optional Allow for making both reset_gpio && enable_gpio as optional in the params by fixing a potential NULL deref and defaulting to zero values. BUG=b:147026979 BRANCH=none TEST=builds Change-Id: I8053d7a080dfed898400c0994bcea492c826fe3d Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/coreboot/+/38522 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/arch/x86/acpi_device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/arch/x86/acpi_device.c b/src/arch/x86/acpi_device.c index d51278975b..1092c7317b 100644 --- a/src/arch/x86/acpi_device.c +++ b/src/arch/x86/acpi_device.c @@ -537,9 +537,9 @@ void acpi_device_write_spi(const struct acpi_spi *spi) void acpi_device_add_power_res(const struct acpi_power_res_params *params) { static const char *power_res_dev_states[] = { "_PR0", "_PR3" }; - unsigned int reset_gpio = params->reset_gpio->pins[0]; - unsigned int enable_gpio = params->enable_gpio->pins[0]; - unsigned int stop_gpio = params->stop_gpio->pins[0]; + unsigned int reset_gpio = params->reset_gpio ? params->reset_gpio->pins[0] : 0; + unsigned int enable_gpio = params->enable_gpio ? params->enable_gpio->pins[0] : 0; + unsigned int stop_gpio = params->stop_gpio ? params->stop_gpio->pins[0] : 0; if (!reset_gpio && !enable_gpio && !stop_gpio) return; -- cgit v1.2.3