diff options
author | Vardan Mikayelyan <mvardan@synopsys.com> | 2018-01-19 14:46:04 +0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2018-03-13 10:47:44 +0200 |
commit | fb50aacdcf124d98ed93d4cc87867aa60011b52d (patch) | |
tree | 298254fa8caff0abbe8431298ef9e674760c6cc3 | |
parent | a127cccd869b4418dcfaefe96bfa672287b32719 (diff) | |
download | linux-stable-fb50aacdcf124d98ed93d4cc87867aa60011b52d.tar.gz linux-stable-fb50aacdcf124d98ed93d4cc87867aa60011b52d.tar.bz2 linux-stable-fb50aacdcf124d98ed93d4cc87867aa60011b52d.zip |
usb: dwc2: pci: Move devm_kzalloc() before platform_device_add()
After platform_device_add(), if we error out, we must do
platform_device_unregister(), which also does the put. So lets move
devm_kzalloc() to simplify error handling and avoid calling of
platform_device_unregister().
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Vardan Mikayelyan <mvardan@synopsys.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Grigor Tovmasyan <tovmasya@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
-rw-r--r-- | drivers/usb/dwc2/pci.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c index 11b8ffb6656b..0943f0d40fe4 100644 --- a/drivers/usb/dwc2/pci.c +++ b/drivers/usb/dwc2/pci.c @@ -140,16 +140,16 @@ static int dwc2_pci_probe(struct pci_dev *pci, if (ret) goto err; + glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); + if (!glue) + return -ENOMEM; + ret = platform_device_add(dwc2); if (ret) { dev_err(dev, "failed to register dwc2 device\n"); goto err; } - glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); - if (!glue) - return -ENOMEM; - glue->phy = phy; glue->dwc2 = dwc2; pci_set_drvdata(pci, glue); |