summaryrefslogtreecommitdiff
path: root/src/drivers/generic
diff options
context:
space:
mode:
authorRichard Spiegel <richard.spiegel@silverbackltd.com>2018-02-14 09:38:11 -0700
committerMartin Roth <martinroth@google.com>2018-02-15 21:39:28 +0000
commite0d306447a13652905f6224163d6c96d5a21e9bf (patch)
tree325881db6932e00b1dad8d116d7f97d166547473 /src/drivers/generic
parent405f72952ceb0d28726cd576228fda43909951b1 (diff)
downloadcoreboot-e0d306447a13652905f6224163d6c96d5a21e9bf.tar.xz
drivers/generic/adau7002/adau7002.c: Fix null pointer dereference
Procedures acpi_device_scope() and acpi_device_name() can under certain conditions return NULL. Check the return before using them. This fixes CID 1385944 BUG=b:73331544 TEST=Build kahlee. Change-Id: Ifcdf905100d22a1d828394f8685641eb432bb836 Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-on: https://review.coreboot.org/23760 Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/drivers/generic')
-rw-r--r--src/drivers/generic/adau7002/adau7002.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/drivers/generic/adau7002/adau7002.c b/src/drivers/generic/adau7002/adau7002.c
index d21d513c59..0a94819ec2 100644
--- a/src/drivers/generic/adau7002/adau7002.c
+++ b/src/drivers/generic/adau7002/adau7002.c
@@ -29,12 +29,17 @@
static void adau7002_fill_ssdt(struct device *dev)
{
- if (!dev->enabled)
+ if (!dev || !dev->enabled)
+ return;
+
+ const char *scope = acpi_device_scope(dev);
+ const char *name = acpi_device_name(dev);
+ if (!scope || !name)
return;
/* Device */
- acpigen_write_scope(acpi_device_scope(dev));
- acpigen_write_device(acpi_device_name(dev));
+ acpigen_write_scope(scope);
+ acpigen_write_device(name);
acpigen_write_name_string("_HID", ADAU7002_ACPI_HID);
acpigen_write_name_integer("_UID", 0);
acpigen_write_name_string("_DDN", dev->chip_ops->name);