[PATCH] ptp_pch: release chip->mem_base and chip->regs on error

From: Yuanhan Liu
Date: Thu Oct 18 2012 - 05:48:37 EST


Fix smatch warnings catched by Fengguang's 0-DAY system:
+ drivers/ptp/ptp_pch.c:641 pch_probe() warn: 'chip->mem_base' was not released on error
+ drivers/ptp/ptp_pch.c:641 pch_probe() warn: 'chip->regs' was not released on error

Cc: Richard Cochran <richardcochran@xxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Yuanhan Liu <yuanhan.liu@xxxxxxxxxxxxxxx>
---
drivers/ptp/ptp_pch.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
index e624e4d..daddd88 100644
--- a/drivers/ptp/ptp_pch.c
+++ b/drivers/ptp/ptp_pch.c
@@ -629,8 +629,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;
+ }

spin_lock_init(&chip->register_lock);

@@ -669,6 +671,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:
iounmap(chip->regs);
chip->regs = 0;

--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/