From: Sebastian Andrzej Siewior Date: Wed, 16 Oct 2013 10:50:06 +0000 (+0200) Subject: usb: musb: core: properly free host / device structs in err path X-Git-Tag: v3.12.2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78bf8811f05d10a9ecdbe5f1825a3b9e6b8d8fed;p=kernel%2Fkernel-generic.git usb: musb: core: properly free host / device structs in err path commit 0d2dd7eaed1dac07b266ca2c662ff4a184a3060f upstream. The patch fixes two issues in the error path cleanup: - in MUSB_PORT_MODE_DUAL_ROLE mode, if musb_gadget_setup() fails we never cleanup the host struct earlier allocated. - if musb_init_debugfs() or sysfs_create_group() fails, then we never free the host part initialization, only device part. Cc: Daniel Mack Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 60dbeba..0d0d118 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1947,6 +1947,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) if (status < 0) goto fail3; status = musb_gadget_setup(musb); + if (status) + musb_host_cleanup(musb); break; default: dev_err(dev, "unsupported port mode %d\n", musb->port_mode); @@ -1973,6 +1975,7 @@ fail5: fail4: musb_gadget_cleanup(musb); + musb_host_cleanup(musb); fail3: if (musb->dma_controller)