Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56264 )
Change subject: drivers/usb/acpi: Fix usb_acpi_get_pld ......................................................................
drivers/usb/acpi: Fix usb_acpi_get_pld
Commit 8e885a57b13a2 introduced a new function and it Coverity found 2 bugs in it:
1) Use before NULL check 2) Incorrect size passed to memcpy()
Found-by: Coverity CID 1458231 Found-by: Coverity CID 1458232
Change-Id: I424ae185f544c13c0638ff57c097d784265f2848 Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M src/drivers/usb/acpi/usb_acpi.c 1 file changed, 3 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/64/56264/1
diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c index a0dadff..395f069 100644 --- a/src/drivers/usb/acpi/usb_acpi.c +++ b/src/drivers/usb/acpi/usb_acpi.c @@ -125,14 +125,15 @@
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) - memcpy(pld, &config->custom_pld, sizeof(pld)); + memcpy(pld, &config->custom_pld, sizeof(*pld)); else acpi_pld_fill_usb(pld, config->type, &config->group);