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>
This commit is contained in:
Родитель
dc1737cdd7
Коммит
70617db7ad
|
@ -268,10 +268,12 @@ omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
|
||||||
struct omap_req *req;
|
struct omap_req *req;
|
||||||
|
|
||||||
req = kzalloc(sizeof(*req), gfp_flags);
|
req = kzalloc(sizeof(*req), gfp_flags);
|
||||||
if (req) {
|
if (!req)
|
||||||
req->req.dma = DMA_ADDR_INVALID;
|
return NULL;
|
||||||
INIT_LIST_HEAD(&req->queue);
|
|
||||||
}
|
req->req.dma = DMA_ADDR_INVALID;
|
||||||
|
INIT_LIST_HEAD(&req->queue);
|
||||||
|
|
||||||
return &req->req;
|
return &req->req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче