diff options
Diffstat (limited to 'drivers/usb/host/xhci-mem.c')
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1f1f8a0f2e66..8045bc69083d 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -267,6 +267,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, | |||
267 | void xhci_free_container_ctx(struct xhci_hcd *xhci, | 267 | void xhci_free_container_ctx(struct xhci_hcd *xhci, |
268 | struct xhci_container_ctx *ctx) | 268 | struct xhci_container_ctx *ctx) |
269 | { | 269 | { |
270 | if (!ctx) | ||
271 | return; | ||
270 | dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); | 272 | dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); |
271 | kfree(ctx); | 273 | kfree(ctx); |
272 | } | 274 | } |
@@ -844,7 +846,8 @@ static void scratchpad_free(struct xhci_hcd *xhci) | |||
844 | } | 846 | } |
845 | 847 | ||
846 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | 848 | struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, |
847 | bool allocate_completion, gfp_t mem_flags) | 849 | bool allocate_in_ctx, bool allocate_completion, |
850 | gfp_t mem_flags) | ||
848 | { | 851 | { |
849 | struct xhci_command *command; | 852 | struct xhci_command *command; |
850 | 853 | ||
@@ -852,11 +855,14 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, | |||
852 | if (!command) | 855 | if (!command) |
853 | return NULL; | 856 | return NULL; |
854 | 857 | ||
855 | command->in_ctx = | 858 | if (allocate_in_ctx) { |
856 | xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, mem_flags); | 859 | command->in_ctx = |
857 | if (!command->in_ctx) { | 860 | xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, |
858 | kfree(command); | 861 | mem_flags); |
859 | return NULL; | 862 | if (!command->in_ctx) { |
863 | kfree(command); | ||
864 | return NULL; | ||
865 | } | ||
860 | } | 866 | } |
861 | 867 | ||
862 | if (allocate_completion) { | 868 | if (allocate_completion) { |