* [PATCH] usb: serial: io_edgeport: fix memory leak in edge_startup
@ 2021-03-01 23:01 Pavel Skripkin
2021-03-05 9:53 ` Johan Hovold
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Skripkin @ 2021-03-01 23:01 UTC (permalink / raw)
To: johan, gregkh
Cc: linux-usb, linux-kernel, Pavel Skripkin, syzbot+59f777bdcbdd7eea5305
sysbot found memory leak in edge_startup().
The problem was that when an error was received from the usb_submit_urb(),
nothing was cleaned up.
Reported-by: syzbot+59f777bdcbdd7eea5305@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
drivers/usb/serial/io_edgeport.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index a493670c06e6..68401adcffde 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -3003,26 +3003,32 @@ static int edge_startup(struct usb_serial *serial)
response = -ENODEV;
}
- usb_free_urb(edge_serial->interrupt_read_urb);
- kfree(edge_serial->interrupt_in_buffer);
-
- usb_free_urb(edge_serial->read_urb);
- kfree(edge_serial->bulk_in_buffer);
-
- kfree(edge_serial);
-
- return response;
+ goto error;
}
/* start interrupt read for this edgeport this interrupt will
* continue as long as the edgeport is connected */
response = usb_submit_urb(edge_serial->interrupt_read_urb,
GFP_KERNEL);
- if (response)
+ if (response) {
dev_err(ddev, "%s - Error %d submitting control urb\n",
__func__, response);
+
+ goto error;
+ }
}
return response;
+
+error:
+ usb_free_urb(edge_serial->interrupt_read_urb);
+ kfree(edge_serial->interrupt_in_buffer);
+
+ usb_free_urb(edge_serial->read_urb);
+ kfree(edge_serial->bulk_in_buffer);
+
+ kfree(edge_serial);
+
+ return response;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: serial: io_edgeport: fix memory leak in edge_startup
2021-03-01 23:01 [PATCH] usb: serial: io_edgeport: fix memory leak in edge_startup Pavel Skripkin
@ 2021-03-05 9:53 ` Johan Hovold
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2021-03-05 9:53 UTC (permalink / raw)
To: Pavel Skripkin
Cc: gregkh, linux-usb, linux-kernel, syzbot+59f777bdcbdd7eea5305
On Tue, Mar 02, 2021 at 02:01:52AM +0300, Pavel Skripkin wrote:
> sysbot found memory leak in edge_startup().
> The problem was that when an error was received from the usb_submit_urb(),
> nothing was cleaned up.
>
> Reported-by: syzbot+59f777bdcbdd7eea5305@syzkaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Now applied, thanks.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-05 9:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 23:01 [PATCH] usb: serial: io_edgeport: fix memory leak in edge_startup Pavel Skripkin
2021-03-05 9:53 ` Johan Hovold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.