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 <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56266
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Angel Pons 2021-07-13 19:08:31 +02:00 committed by Tim Wawrzynczak
parent afab34c372
commit dd405bc018
1 changed files with 2 additions and 1 deletions

View File

@ -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) 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 || if (!usb_device || !usb_device->chip_info ||
usb_device->chip_ops != &drivers_usb_acpi_ops) usb_device->chip_ops != &drivers_usb_acpi_ops)
return false; return false;
config = usb_device->chip_info;
if (config->use_custom_pld) if (config->use_custom_pld)
*pld = config->custom_pld; *pld = config->custom_pld;
else else