diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2014-01-14 13:37:46 +0530 |
---|---|---|
committer | Avik Sil <aviksil@linux.vnet.ibm.com> | 2014-01-20 17:19:47 +0530 |
commit | 673997ee749f8e8d0659a9864b8bfa8b069bf400 (patch) | |
tree | b20deeff1258417b9fb5917a80ece33c5623eba6 /lib/libusb/usb-xhci.c | |
parent | dd53579ae82bed0654dd3e4b3052ef2cac58b5f4 (diff) | |
download | SLOF-673997ee749f8e8d0659a9864b8bfa8b069bf400.zip SLOF-673997ee749f8e8d0659a9864b8bfa8b069bf400.tar.gz SLOF-673997ee749f8e8d0659a9864b8bfa8b069bf400.tar.bz2 |
[oex]hci_exit: Check before freeing/unmapping memory
While doing cleanup of the allocated memory, make sure addresses being
unmapped/free were really allocated. During error conditions, some
address would not have been.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Diffstat (limited to 'lib/libusb/usb-xhci.c')
-rw-r--r-- | lib/libusb/usb-xhci.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c index 5c8b1a4..d731eb1 100644 --- a/lib/libusb/usb-xhci.c +++ b/lib/libusb/usb-xhci.c @@ -829,16 +829,20 @@ static bool xhci_hcd_exit(struct xhci_hcd *xhcd) irs = &xhcd->run_regs->irs[0]; write_reg64(&irs->erstba, 0); mb(); - SLOF_dma_map_out(xhcd->erst.dma, xhcd->erst.entries, XHCI_EVENT_TRBS_SIZE); - SLOF_dma_free(xhcd->erst.entries, XHCI_EVENT_TRBS_SIZE); + if (xhcd->erst.entries) { + SLOF_dma_map_out(xhcd->erst.dma, xhcd->erst.entries, XHCI_EVENT_TRBS_SIZE); + SLOF_dma_free(xhcd->erst.entries, XHCI_EVENT_TRBS_SIZE); + } xhci_free_seg(&xhcd->ering, XHCI_EVENT_TRBS_SIZE); val = read_reg64(&op->crcr) & ~XHCI_CRCR_CRP_MASK; write_reg64(&op->crcr, val); xhci_free_seg(&xhcd->crseg, XHCI_CRCR_CRP_SIZE); write_reg64(&op->dcbaap, 0); - SLOF_dma_map_out(xhcd->dcbaap_dma, (void *)xhcd->dcbaap, XHCI_DCBAAP_MAX_SIZE); - SLOF_dma_free((void *)xhcd->dcbaap, XHCI_DCBAAP_MAX_SIZE); + if (xhcd->dcbaap) { + SLOF_dma_map_out(xhcd->dcbaap_dma, (void *)xhcd->dcbaap, XHCI_DCBAAP_MAX_SIZE); + SLOF_dma_free((void *)xhcd->dcbaap, XHCI_DCBAAP_MAX_SIZE); + } return true; } |