mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: mv_u3d_core: fix memory leaks
@ 2013-09-21  9:30 Valentin Ilie
  2013-09-26 11:14 ` Valentin Ilie
  0 siblings, 1 reply; 2+ messages in thread
From: Valentin Ilie @ 2013-09-21  9:30 UTC (permalink / raw)
  To: balbi, gregkh; +Cc: linux-usb, linux-kernel, Valentin Ilie

When trb_hw is NULL, trb should be free'd before return.

Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com>
---
 drivers/usb/gadget/mv_u3d_core.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index 561b30e..4d31177 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -310,6 +310,7 @@ static struct mv_u3d_trb *mv_u3d_build_trb_one(struct mv_u3d_req *req,
 	 */
 	trb_hw = dma_pool_alloc(u3d->trb_pool, GFP_ATOMIC, dma);
 	if (!trb_hw) {
+		kfree(trb);
 		dev_err(u3d->dev,
 			"%s, dma_pool_alloc fail\n", __func__);
 		return NULL;
@@ -454,6 +455,7 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req)
 
 		trb_hw = kcalloc(trb_num, sizeof(*trb_hw), GFP_ATOMIC);
 		if (!trb_hw) {
+			kfree(trb);
 			dev_err(u3d->dev,
 					"%s, trb_hw alloc fail\n", __func__);
 			return -ENOMEM;
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-26 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-21  9:30 [PATCH] usb: gadget: mv_u3d_core: fix memory leaks Valentin Ilie
2013-09-26 11:14 ` Valentin Ilie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®