aboutsummaryrefslogtreecommitdiffstats
path: root/usb.current/usb-ehci-ppc-of-problems-in-unwind.patch
blob: 045db42a9f1fcb285c3eb9f36417d9cd54068b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From error27@gmail.com  Wed Sep  1 12:41:29 2010
Date: Sat, 14 Aug 2010 11:06:19 +0200
From: Dan Carpenter <error27@gmail.com>
To: David Brownell <dbrownell@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	Grant Likely <grant.likely@secretlab.ca>,
	Sean MacLennan <smaclennan@pikatech.com>,
	"David S. Miller" <davem@davemloft.net>, linux-usb@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org,
	Vitaly Bordug <vitb@kernel.crashing.org>,
	kernel-janitors@vger.kernel.org
Subject: USB: ehci-ppc-of: problems in unwind
Message-ID: <20100814090619.GY645@bicker>
Content-Disposition: inline

The iounmap(ehci->ohci_hcctrl_reg); should be the first thing we do
because the ioremap() was the last thing we did.  Also if we hit any of
the goto statements in the original code then it would have led to a
NULL dereference of "ehci".  This bug was introduced in: 796bcae7361c
"USB: powerpc: Workaround for the PPC440EPX USBH_23 errata [take 3]"

I modified the few lines in front a little so that my code didn't
obscure the return success code path.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Grant Likely <grant.likely@secretlab.ca>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/host/ehci-ppc-of.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -192,17 +192,19 @@ ehci_hcd_ppc_of_probe(struct platform_de
 	}
 
 	rv = usb_add_hcd(hcd, irq, 0);
-	if (rv == 0)
-		return 0;
+	if (rv)
+		goto err_ehci;
 
+	return 0;
+
+err_ehci:
+	if (ehci->has_amcc_usb23)
+		iounmap(ehci->ohci_hcctrl_reg);
 	iounmap(hcd->regs);
 err_ioremap:
 	irq_dispose_mapping(irq);
 err_irq:
 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
-	if (ehci->has_amcc_usb23)
-		iounmap(ehci->ohci_hcctrl_reg);
 err_rmr:
 	usb_put_hcd(hcd);