提交 29f9d54b 编写于 作者: S Sarah Sharp

xhci: Remove BUG_ON() in xhci_alloc_container_ctx.

It's horrible coding style to panic the kernel when someone passes you
an argument value you didn't expect.  In the future, we may want to add
additional context types, so it's better to gracefully handle additional
context types instead of panicking.
Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: John Youn <johnyoun@synopsys.com>
上级 976f8bef
...@@ -358,11 +358,15 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, ...@@ -358,11 +358,15 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring,
static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
int type, gfp_t flags) int type, gfp_t flags)
{ {
struct xhci_container_ctx *ctx = kzalloc(sizeof(*ctx), flags); struct xhci_container_ctx *ctx;
if ((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT))
return NULL;
ctx = kzalloc(sizeof(*ctx), flags);
if (!ctx) if (!ctx)
return NULL; return NULL;
BUG_ON((type != XHCI_CTX_TYPE_DEVICE) && (type != XHCI_CTX_TYPE_INPUT));
ctx->type = type; ctx->type = type;
ctx->size = HCC_64BYTE_CONTEXT(xhci->hcc_params) ? 2048 : 1024; ctx->size = HCC_64BYTE_CONTEXT(xhci->hcc_params) ? 2048 : 1024;
if (type == XHCI_CTX_TYPE_INPUT) if (type == XHCI_CTX_TYPE_INPUT)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册