From dd405bc018e3730d0afddfd1cc5f18c6d5fd9794 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Tue, 13 Jul 2021 19:08:31 +0200 Subject: drivers/usb/acpi: Avoid dereferencing maybe-NULL pointer Do not dereference a pointer before checking whether it is NULL. Change-Id: Icbe9ae99d91fd587d8e56cf3a0dcb59834ee6d07 Found-by: Coverity CID 1458232 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/56266 Reviewed-by: Tim Wawrzynczak Reviewed-by: Furquan Shaikh Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- src/drivers/usb/acpi/usb_acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/drivers') diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c index 8ada939138..fb9f7f198f 100644 --- a/src/drivers/usb/acpi/usb_acpi.c +++ b/src/drivers/usb/acpi/usb_acpi.c @@ -125,12 +125,13 @@ struct chip_operations drivers_usb_acpi_ops = { bool usb_acpi_get_pld(const struct device *usb_device, struct acpi_pld *pld) { - struct drivers_usb_acpi_config *config = usb_device->chip_info; + struct drivers_usb_acpi_config *config; if (!usb_device || !usb_device->chip_info || usb_device->chip_ops != &drivers_usb_acpi_ops) return false; + config = usb_device->chip_info; if (config->use_custom_pld) *pld = config->custom_pld; else -- cgit v1.2.3