drivers/generic/max98357a: Add extra error handling

It is possible that acpi_device_scope() and acpi_device_name() can
return NULL to indicate an error, so add error handling to check their
return values.

Change-Id: I4c7ab0c592845d9d5f142e078fc2b505a99ecd12
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1362592
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33028
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Jacob Garber 2019-05-27 17:10:24 -06:00 committed by Patrick Georgi
parent 924463d1a5
commit bdcb4d3750
1 changed files with 7 additions and 2 deletions

View File

@ -36,9 +36,14 @@ static void max98357a_fill_ssdt(struct device *dev)
if (!dev->enabled || !config) if (!dev->enabled || !config)
return; return;
const char *scope = acpi_device_scope(dev);
const char *name = acpi_device_name(dev);
if (!scope || !name)
return;
/* Device */ /* Device */
acpigen_write_scope(acpi_device_scope(dev)); acpigen_write_scope(scope);
acpigen_write_device(acpi_device_name(dev)); acpigen_write_device(name);
acpigen_write_name_string("_HID", MAX98357A_ACPI_HID); acpigen_write_name_string("_HID", MAX98357A_ACPI_HID);
acpigen_write_name_integer("_UID", 0); acpigen_write_name_integer("_UID", 0);
acpigen_write_name_string("_DDN", dev->chip_ops->name); acpigen_write_name_string("_DDN", dev->chip_ops->name);