Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1457508
| From | Alexey Klimov <klimov.linux@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] USB: serial: fix memleak on error path in usb-serial |
| Date | 2016-08-08 03:40 +0200 |
| Message-ID | <s3HHP-34Z-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
udriver struct allocated by kzalloc() will not be freed
if usb_register() and next calls fail. This patch fixes this
by adding one more step with kfree(udriver) in error path.
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
---
drivers/usb/serial/usb-serial.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b1b9bac..d213cf4 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1433,7 +1433,7 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[]
rc = usb_register(udriver);
if (rc)
- return rc;
+ goto failed_usb_register;
for (sd = serial_drivers; *sd; ++sd) {
(*sd)->usb_driver = udriver;
@@ -1451,6 +1451,8 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[]
while (sd-- > serial_drivers)
usb_serial_deregister(*sd);
usb_deregister(udriver);
+failed_usb_register:
+ kfree(udriver);
return rc;
}
EXPORT_SYMBOL_GPL(usb_serial_register_drivers);
--
2.5.0
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] USB: serial: fix memleak on error path in usb-serial Alexey Klimov <klimov.linux@gmail.com> - 2016-08-08 03:40 +0200 Re: [PATCH] USB: serial: fix memleak on error path in usb-serial Alan Stern <stern@rowland.harvard.edu> - 2016-08-08 03:50 +0200 Re: [PATCH] USB: serial: fix memleak on error path in usb-serial Johan Hovold <johan@kernel.org> - 2016-08-08 13:50 +0200
csiph-web