lkml.org 
[lkml]   [2018]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] usb:gadget:function:fix memory leak
Date
In function f_audio_set_alt(), the memory allocated by
usb_ep_alloc_request() is not released on the error path
that req->buf, which holds the return value of kzalloc(),
is NULL. This will result in a memory leak bug.

Signed-off-by: Xidong Wang <wangxidong_97@163.com>
---
drivers/usb/gadget/function/f_uac1_legacy.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/gadget/function/f_uac1_legacy.c
index 24c086b..2fcdade 100644
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -630,8 +630,11 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
ERROR(cdev,
"%s queue req: %d\n",
out_ep->name, err);
- } else
+ } else {
+ usb_ep_free_request(
+ out_ep, req);
err = -ENOMEM;
+ }
} else
err = -ENOMEM;
}
--
2.7.4

\
 
 \ /
  Last update: 2018-07-23 13:11    [W:0.065 / U:7.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site