ptp_pch: fix error handling in pch_probe()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Wed, 22 May 2013 23:59:28 +0000 (23:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 26 May 2013 04:24:15 +0000 (21:24 -0700)
Fix to release resources when ptp_clock_register() fail instead
of return error code directly.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ptp/ptp_pch.c

index bea94510ad2d4c0d3faf7cc703c9b8883ec9cf97..71a2559278d7a0d41bf773edcf5219f35462ddb1 100644 (file)
@@ -628,9 +628,10 @@ pch_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        chip->caps = ptp_pch_caps;
        chip->ptp_clock = ptp_clock_register(&chip->caps, &pdev->dev);
-
-       if (IS_ERR(chip->ptp_clock))
-               return PTR_ERR(chip->ptp_clock);
+       if (IS_ERR(chip->ptp_clock)) {
+               ret = PTR_ERR(chip->ptp_clock);
+               goto err_ptp_clock_reg;
+       }
 
        spin_lock_init(&chip->register_lock);
 
@@ -669,6 +670,7 @@ pch_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 err_req_irq:
        ptp_clock_unregister(chip->ptp_clock);
+err_ptp_clock_reg:
        iounmap(chip->regs);
        chip->regs = NULL;