Commit 56770f67 authored by Evgeny Novikov's avatar Evgeny Novikov Committed by Khalid Elmously

usb: gadget: udc: gr_udc: fix memleak on error handling path in gr_ep_init()

BugLink: https://bugs.launchpad.net/bugs/1889928

[ Upstream commit c8f8529e ]

gr_ep_init() does not assign the allocated request anywhere if allocation
of memory for the buffer fails. This is a memory leak fixed by the given
patch.

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 02dea3ac
...@@ -2001,9 +2001,12 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) ...@@ -2001,9 +2001,12 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
if (num == 0) { if (num == 0) {
_req = gr_alloc_request(&ep->ep, GFP_ATOMIC); _req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
if (!_req)
return -ENOMEM;
buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC); buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
if (!_req || !buf) { if (!buf) {
/* possible _req freed by gr_probe via gr_remove */ gr_free_request(&ep->ep, _req);
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment