aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/usb-xhci.c
diff options
context:
space:
mode:
authorNikunj A Dadhania <nikunj@linux.vnet.ibm.com>2014-01-14 13:37:46 +0530
committerAvik Sil <aviksil@linux.vnet.ibm.com>2014-01-20 17:19:47 +0530
commit673997ee749f8e8d0659a9864b8bfa8b069bf400 (patch)
treeb20deeff1258417b9fb5917a80ece33c5623eba6 /lib/libusb/usb-xhci.c
parentdd53579ae82bed0654dd3e4b3052ef2cac58b5f4 (diff)
downloadSLOF-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.c12
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;
}