DM USB: Fix potential crash issues.

This patch fix some potential crash issues, like wild
pointers access, buffer overflow and etc.

Change-Id: Iddd8e1820da426adc6b9b4d9da9e44017d9f365c
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Xiaoguang Wu
2018-06-04 09:59:40 +08:00
committed by lijinxia
parent e3346754e1
commit c34360b6b8
2 changed files with 13 additions and 4 deletions

View File

@@ -748,7 +748,8 @@ pci_xhci_dev_destroy(struct pci_xhci_dev_emu *de)
if (ue->ue_deinit)
ue->ue_deinit(ud);
}
}
} else
return;
if (ue->ue_devtype == USB_DEV_PORT_MAPPER)
free(ue);
@@ -3314,7 +3315,8 @@ pci_xhci_parse_bus_port(struct pci_xhci_vdev *xdev, char *opts)
/* 'bus-port' format */
cnt = sscanf(opts, "%u-%u", &bus, &port);
if (cnt == EOF || cnt < 2) {
if (cnt == EOF || cnt < 2 || bus >= USB_NATIVE_NUM_BUS ||
port >= USB_NATIVE_NUM_PORT) {
rc = -1;
goto errout;
}
@@ -3534,7 +3536,10 @@ errout:
xdev->portregs = NULL;
}
UPRINTF(LFTL, "fail to parse xHCI options, rc=%d\r\n", rc);
pci_xhci_device_usage(opts);
if (opts)
pci_xhci_device_usage(opts);
return rc;
}