[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200626131747.18276-1-novikov@ispras.ru>
Date: Fri, 26 Jun 2020 16:17:47 +0300
From: Evgeny Novikov <novikov@...ras.ru>
To: Felipe Balbi <balbi@...nel.org>
Cc: Evgeny Novikov <novikov@...ras.ru>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Matthias Brugger <matthias.bgg@...il.com>,
YueHaibing <yuehaibing@...wei.com>,
Jason Yan <yanaijie@...wei.com>,
Jia-Ju Bai <baijiaju1990@...il.com>,
Stephen Boyd <swboyd@...omium.org>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, ldv-project@...uxtesting.org
Subject: [PATCH] usb: gadget: udc: gr_udc: fix memleak on error handling path in gr_ep_init()
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: Evgeny Novikov <novikov@...ras.ru>
---
drivers/usb/gadget/udc/gr_udc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 7164ad9800f1..7419889ebe9a 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -1980,9 +1980,12 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
if (num == 0) {
_req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
+ if (!_req)
+ return -ENOMEM;
+
buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
- if (!_req || !buf) {
- /* possible _req freed by gr_probe via gr_remove */
+ if (!buf) {
+ gr_free_request(&ep->ep, _req);
return -ENOMEM;
}
--
2.16.4
Powered by blists - more mailing lists