summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/omap_udc.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2012-05-29 14:36:42 +0300
committerFelipe Balbi <balbi@ti.com>2012-06-03 23:11:33 +0300
commit70617db7ad7395498e6bc54c634199bf895426c6 (patch)
tree2f3b5fef60c3e25e753347cca184131dcaaa4177 /drivers/usb/gadget/omap_udc.c
parentdc1737cdd75b692dbdec0e0e22439a0ce1089488 (diff)
usb: gadget: omap_udc: remove possiblity of NULL pointer de-reference
when allocating a request, it's better programming practice to make sure we return NULL if allocation failed. This will ensure that, if struct usb_request isn't the first member on our structure, we don't cheat the gadget driver into thinking allocating worked because pointer isn't 0. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/omap_udc.c')
-rw-r--r--drivers/usb/gadget/omap_udc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 814aafbed00..f13bcdc7567 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -268,10 +268,12 @@ omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
struct omap_req *req;
req = kzalloc(sizeof(*req), gfp_flags);
- if (req) {
- req->req.dma = DMA_ADDR_INVALID;
- INIT_LIST_HEAD(&req->queue);
- }
+ if (!req)
+ return NULL;
+
+ req->req.dma = DMA_ADDR_INVALID;
+ INIT_LIST_HEAD(&req->queue);
+
return &req->req;
}