ehci-ppc-of: problems in unwind
Subsystems (3)
PATCH 1/1 ehci-ppc-of: problems in unwind
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.
---
I don't have a cross compile environment set up so I haven't compiled this code. Sorry for that.
drivers/usb/host/ehci-ppc-of.c +7 -5
@@ -192,17 +192,19 @@ ehci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *mat } 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);
Quoted 10 lines · Dan Carpenter
The
iounmap(ehci->ohci_hcctrl_reg); should be the first thing we do because theioremap()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 PPC440EPXUSBH_23errata [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 <[email protected]>
Looks correct, but I don't have the hardware to test.
g.
Quoted 34 lines
---
I don't have a cross compile environment set up so I haven't compiled this code. Sorry for that.drivers/usb/host/ehci-ppc-of.c +7
-2@@ -192,17 +192,19 @@ ehci_hcd_ppc_of_probe(struct platform_device *op, const struct of_device_id *mat } 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);
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html