xhci: check for failed dma pool allocation
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / xhci-mem.c
index fbf75e57628b72e0b7a74237d8a9610826b2ab93..f2e57a1112c93c2c1291df41782c5ba97057af75 100644 (file)
@@ -369,6 +369,10 @@ static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci
                ctx->size += CTX_SIZE(xhci->hcc_params);
 
        ctx->bytes = dma_pool_alloc(xhci->device_pool, flags, &ctx->dma);
+       if (!ctx->bytes) {
+               kfree(ctx);
+               return NULL;
+       }
        memset(ctx->bytes, 0, ctx->size);
        return ctx;
 }