[PATCH] usb : Free previuos allocated memory when function call fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.linux@xxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux