aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-01 11:03:54 +0200
committerFelipe Balbi <balbi@ti.com>2010-12-01 11:03:54 +0200
commit0607f8622953541e95030ab011258d9f1f381357 (patch)
tree3958a9076d3a31a091a250f6ac21331346b2520d /drivers/usb/musb
parentfcf173e4511193b1efeccb0f22a8c641b464353b (diff)
downloadkernel_samsung_aries-0607f8622953541e95030ab011258d9f1f381357.zip
kernel_samsung_aries-0607f8622953541e95030ab011258d9f1f381357.tar.gz
kernel_samsung_aries-0607f8622953541e95030ab011258d9f1f381357.tar.bz2
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')
-rw-r--r--drivers/usb/musb/musb_gadget.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 5d81504..edff014 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)
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;
}