Skip to content

Commit

Permalink
usb: gadget: omap_udc: remove possiblity of NULL pointer de-reference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Balbi committed Jun 3, 2012
1 parent dc1737c commit 70617db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/usb/gadget/omap_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 70617db

Please sign in to comment.