]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.10.67/sata_dwc_460ex-fix-resource-leak-on-error-path.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.67 / sata_dwc_460ex-fix-resource-leak-on-error-path.patch
1 From 4aaa71873ddb9faf4b0c4826579e2f6d18ff9ab4 Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Wed, 7 Jan 2015 15:24:19 +0200
4 Subject: sata_dwc_460ex: fix resource leak on error path
5
6 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
7
8 commit 4aaa71873ddb9faf4b0c4826579e2f6d18ff9ab4 upstream.
9
10 DMA mapped IO should be unmapped on the error path in probe() and
11 unconditionally on remove().
12
13 Fixes: 62936009f35a ([libata] Add 460EX on-chip SATA driver, sata_dwc_460ex)
14 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
15 Signed-off-by: Tejun Heo <tj@kernel.org>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18 ---
19 drivers/ata/sata_dwc_460ex.c | 26 ++++++++++++--------------
20 1 file changed, 12 insertions(+), 14 deletions(-)
21
22 --- a/drivers/ata/sata_dwc_460ex.c
23 +++ b/drivers/ata/sata_dwc_460ex.c
24 @@ -797,7 +797,7 @@ static int dma_dwc_init(struct sata_dwc_
25 if (err) {
26 dev_err(host_pvt.dwc_dev, "%s: dma_request_interrupts returns"
27 " %d\n", __func__, err);
28 - goto error_out;
29 + return err;
30 }
31
32 /* Enabe DMA */
33 @@ -808,11 +808,6 @@ static int dma_dwc_init(struct sata_dwc_
34 sata_dma_regs);
35
36 return 0;
37 -
38 -error_out:
39 - dma_dwc_exit(hsdev);
40 -
41 - return err;
42 }
43
44 static int sata_dwc_scr_read(struct ata_link *link, unsigned int scr, u32 *val)
45 @@ -1662,7 +1657,7 @@ static int sata_dwc_probe(struct platfor
46 char *ver = (char *)&versionr;
47 u8 *base = NULL;
48 int err = 0;
49 - int irq, rc;
50 + int irq;
51 struct ata_host *host;
52 struct ata_port_info pi = sata_dwc_port_info[0];
53 const struct ata_port_info *ppi[] = { &pi, NULL };
54 @@ -1725,7 +1720,7 @@ static int sata_dwc_probe(struct platfor
55 if (irq == NO_IRQ) {
56 dev_err(&ofdev->dev, "no SATA DMA irq\n");
57 err = -ENODEV;
58 - goto error_out;
59 + goto error_iomap;
60 }
61
62 /* Get physical SATA DMA register base address */
63 @@ -1734,14 +1729,16 @@ static int sata_dwc_probe(struct platfor
64 dev_err(&ofdev->dev, "ioremap failed for AHBDMA register"
65 " address\n");
66 err = -ENODEV;
67 - goto error_out;
68 + goto error_iomap;
69 }
70
71 /* Save dev for later use in dev_xxx() routines */
72 host_pvt.dwc_dev = &ofdev->dev;
73
74 /* Initialize AHB DMAC */
75 - dma_dwc_init(hsdev, irq);
76 + err = dma_dwc_init(hsdev, irq);
77 + if (err)
78 + goto error_dma_iomap;
79
80 /* Enable SATA Interrupts */
81 sata_dwc_enable_interrupts(hsdev);
82 @@ -1759,9 +1756,8 @@ static int sata_dwc_probe(struct platfor
83 * device discovery process, invoking our port_start() handler &
84 * error_handler() to execute a dummy Softreset EH session
85 */
86 - rc = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
87 -
88 - if (rc != 0)
89 + err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
90 + if (err)
91 dev_err(&ofdev->dev, "failed to activate host");
92
93 dev_set_drvdata(&ofdev->dev, host);
94 @@ -1770,7 +1766,8 @@ static int sata_dwc_probe(struct platfor
95 error_out:
96 /* Free SATA DMA resources */
97 dma_dwc_exit(hsdev);
98 -
99 +error_dma_iomap:
100 + iounmap((void __iomem *)host_pvt.sata_dma_regs);
101 error_iomap:
102 iounmap(base);
103 error_kmalloc:
104 @@ -1791,6 +1788,7 @@ static int sata_dwc_remove(struct platfo
105 /* Free SATA DMA resources */
106 dma_dwc_exit(hsdev);
107
108 + iounmap((void __iomem *)host_pvt.sata_dma_regs);
109 iounmap(hsdev->reg_base);
110 kfree(hsdev);
111 kfree(host);