In usb_parse_interface() when usb_parse_endpoint() fails it returns
error whithout freeing alt->endpoint and we may have a memory leak.
Fix this by freeing alt->endpoint before return.

Signed-off-by: Souptick joarder <jrdr.li...@gmail.com>
---
 drivers/usb/core/config.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index a2d90ac..6f599b6 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -492,8 +492,10 @@ static int usb_parse_interface(struct device *ddev, int 
cfgno,
                        break;
                retval = usb_parse_endpoint(ddev, cfgno, inum, asnum, alt,
                    num_ep, buffer, size);
-               if (retval < 0)
+               if (retval < 0) {
+                       kfree(alt->endpoint);
                        return retval;
+               }
                ++n;
 
                buffer += retval;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to