mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-02 09:25:17 +00:00
dm: usb: fix possible memory leak
fix possible memory leak for usb. Tracked-On: #2705 Signed-off-by: Conghui Chen <conghui.chen@intel.com> Reviewed-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
@@ -4142,8 +4142,8 @@ errout:
|
|||||||
for (i = 1; i <= XHCI_MAX_DEVS && xdev->devices[i]; i++)
|
for (i = 1; i <= XHCI_MAX_DEVS && xdev->devices[i]; i++)
|
||||||
free(xdev->devices[i]);
|
free(xdev->devices[i]);
|
||||||
xdev->ndevices = 0;
|
xdev->ndevices = 0;
|
||||||
xdev->devices = NULL;
|
|
||||||
free(xdev->devices);
|
free(xdev->devices);
|
||||||
|
xdev->devices = NULL;
|
||||||
}
|
}
|
||||||
if (xdev->slots) {
|
if (xdev->slots) {
|
||||||
free(xdev->slots);
|
free(xdev->slots);
|
||||||
@@ -4301,8 +4301,22 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||||||
done:
|
done:
|
||||||
if (error) {
|
if (error) {
|
||||||
UPRINTF(LFTL, "%s fail, error=%d\n", __func__, error);
|
UPRINTF(LFTL, "%s fail, error=%d\n", __func__, error);
|
||||||
|
if (xdev) {
|
||||||
|
if (xdev->devices) {
|
||||||
|
free(xdev->devices);
|
||||||
|
xdev->devices = NULL;
|
||||||
|
}
|
||||||
|
if (xdev->slots) {
|
||||||
|
free(xdev->slots);
|
||||||
|
xdev->slots = NULL;
|
||||||
|
}
|
||||||
|
if (xdev->portregs) {
|
||||||
|
free(xdev->portregs);
|
||||||
|
xdev->portregs = NULL;
|
||||||
|
}
|
||||||
free(xdev);
|
free(xdev);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@@ -868,6 +868,12 @@ usb_dev_data(void *pdata, struct usb_data_xfer *xfer, int dir, int epctx)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
UPRINTF(LFTL, "%s: wrong endpoint type %d\r\n", __func__, type);
|
UPRINTF(LFTL, "%s: wrong endpoint type %d\r\n", __func__, type);
|
||||||
|
|
||||||
|
if (req->buffer)
|
||||||
|
free(req->buffer);
|
||||||
|
if (req->libusb_xfer)
|
||||||
|
libusb_free_transfer(req->libusb_xfer);
|
||||||
|
free(req);
|
||||||
xfer->status = USB_ERR_INVAL;
|
xfer->status = USB_ERR_INVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user