Commit 0607f862 authored by Felipe Balbi's avatar Felipe Balbi

usb: musb: gadget: prevent a NULL pointer dereference

Case we can't allocate struct musb_request,
prevent a NULL pointer dereference by returning
early.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent fcf173e4
......@@ -1072,13 +1072,16 @@ struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
struct musb_request *request = NULL;
request = kzalloc(sizeof *request, gfp_flags);
if (request) {
INIT_LIST_HEAD(&request->request.list);
request->request.dma = DMA_ADDR_INVALID;
request->epnum = musb_ep->current_epnum;
request->ep = musb_ep;
if (!request) {
DBG(4, "not enough memory\n");
return NULL;
}
INIT_LIST_HEAD(&request->request.list);
request->request.dma = DMA_ADDR_INVALID;
request->epnum = musb_ep->current_epnum;
request->ep = musb_ep;
return &request->request;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment