diff options
author | Felipe Balbi <balbi@ti.com> | 2010-12-01 04:03:54 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2010-12-01 04:03:54 -0500 |
commit | 0607f8622953541e95030ab011258d9f1f381357 (patch) | |
tree | 3958a9076d3a31a091a250f6ac21331346b2520d /drivers/usb/musb/musb_gadget.c | |
parent | fcf173e4511193b1efeccb0f22a8c641b464353b (diff) |
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: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/musb_gadget.c')
-rw-r--r-- | drivers/usb/musb/musb_gadget.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 5d815049cbaa..edff014edd3a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1072,13 +1072,16 @@ struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) | |||
1072 | struct musb_request *request = NULL; | 1072 | struct musb_request *request = NULL; |
1073 | 1073 | ||
1074 | request = kzalloc(sizeof *request, gfp_flags); | 1074 | request = kzalloc(sizeof *request, gfp_flags); |
1075 | if (request) { | 1075 | if (!request) { |
1076 | INIT_LIST_HEAD(&request->request.list); | 1076 | DBG(4, "not enough memory\n"); |
1077 | request->request.dma = DMA_ADDR_INVALID; | 1077 | return NULL; |
1078 | request->epnum = musb_ep->current_epnum; | ||
1079 | request->ep = musb_ep; | ||
1080 | } | 1078 | } |
1081 | 1079 | ||
1080 | INIT_LIST_HEAD(&request->request.list); | ||
1081 | request->request.dma = DMA_ADDR_INVALID; | ||
1082 | request->epnum = musb_ep->current_epnum; | ||
1083 | request->ep = musb_ep; | ||
1084 | |||
1082 | return &request->request; | 1085 | return &request->request; |
1083 | } | 1086 | } |
1084 | 1087 | ||