Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-10-15 17:48:50 +0200
committerTakashi Iwai <tiwai@suse.de>2018-10-15 17:49:24 +0200
commit6b722538ab5eb13c534bffb05e192a99694e7ba8 (patch)
tree1c04ab8b7061f34b122860bcb8f5596422c39843
parentfac9285c6ecdb84279d68060c9ae649f192cb4ce (diff)
usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
(bsc#1051510).
-rw-r--r--patches.drivers/usb-gadget-fotg210-udc-Fix-memory-leak-of-fotg210-ep.patch91
-rw-r--r--series.conf1
2 files changed, 92 insertions, 0 deletions
diff --git a/patches.drivers/usb-gadget-fotg210-udc-Fix-memory-leak-of-fotg210-ep.patch b/patches.drivers/usb-gadget-fotg210-udc-Fix-memory-leak-of-fotg210-ep.patch
new file mode 100644
index 0000000000..250476144c
--- /dev/null
+++ b/patches.drivers/usb-gadget-fotg210-udc-Fix-memory-leak-of-fotg210-ep.patch
@@ -0,0 +1,91 @@
+From c37bd52836296ecc9a0fc8060b819089aebdbcde Mon Sep 17 00:00:00 2001
+From: Anton Vasilyev <vasilyev@ispras.ru>
+Date: Tue, 7 Aug 2018 14:44:48 +0300
+Subject: [PATCH] usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
+Git-commit: c37bd52836296ecc9a0fc8060b819089aebdbcde
+Patch-mainline: v4.19-rc4
+References: bsc#1051510
+
+There is no deallocation of fotg210->ep[i] elements, allocated at
+fotg210_udc_probe.
+
+The patch adds deallocation of fotg210->ep array elements and simplifies
+error path of fotg210_udc_probe().
+
+Found by Linux Driver Verification project (linuxtesting.org).
+
+Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
+Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/usb/gadget/udc/fotg210-udc.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
+index 53a48f561458..587c5037ff07 100644
+--- a/drivers/usb/gadget/udc/fotg210-udc.c
++++ b/drivers/usb/gadget/udc/fotg210-udc.c
+@@ -1063,12 +1063,15 @@ static const struct usb_gadget_ops fotg210_gadget_ops = {
+ static int fotg210_udc_remove(struct platform_device *pdev)
+ {
+ struct fotg210_udc *fotg210 = platform_get_drvdata(pdev);
++ int i;
+
+ usb_del_gadget_udc(&fotg210->gadget);
+ iounmap(fotg210->reg);
+ free_irq(platform_get_irq(pdev, 0), fotg210);
+
+ fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
++ for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
++ kfree(fotg210->ep[i]);
+ kfree(fotg210);
+
+ return 0;
+@@ -1099,7 +1102,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
+ /* initialize udc */
+ fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL);
+ if (fotg210 == NULL)
+- goto err_alloc;
++ goto err;
+
+ for (i = 0; i < FOTG210_MAX_NUM_EP; i++) {
+ _ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL);
+@@ -1111,7 +1114,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
+ fotg210->reg = ioremap(res->start, resource_size(res));
+ if (fotg210->reg == NULL) {
+ pr_err("ioremap error.\n");
+- goto err_map;
++ goto err_alloc;
+ }
+
+ spin_lock_init(&fotg210->lock);
+@@ -1159,7 +1162,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
+ fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep,
+ GFP_KERNEL);
+ if (fotg210->ep0_req == NULL)
+- goto err_req;
++ goto err_map;
+
+ fotg210_init(fotg210);
+
+@@ -1187,12 +1190,14 @@ static int fotg210_udc_probe(struct platform_device *pdev)
+ fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
+
+ err_map:
+- if (fotg210->reg)
+- iounmap(fotg210->reg);
++ iounmap(fotg210->reg);
+
+ err_alloc:
++ for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
++ kfree(fotg210->ep[i]);
+ kfree(fotg210);
+
++err:
+ return ret;
+ }
+
+--
+2.19.0
+
diff --git a/series.conf b/series.conf
index ed874b5911..c93a14eee9 100644
--- a/series.conf
+++ b/series.conf
@@ -17746,6 +17746,7 @@
patches.drivers/USB-serial-io_ti-fix-array-underflow-in-completion-h.patch
patches.drivers/USB-serial-ti_usb_3410_5052-fix-array-underflow-in-c.patch
patches.drivers/USB-net2280-Fix-erroneous-synchronization-change.patch
+ patches.drivers/usb-gadget-fotg210-udc-Fix-memory-leak-of-fotg210-ep.patch
patches.drivers/usb-gadget-udc-renesas_usb3-fix-maxpacket-size-of-ep.patch
patches.drivers/Revert-cdc-acm-implement-put_char-and-flush_chars.patch
patches.fixes/cifs-integer-overflow-in-in-SMB2_ioctl.patch