Commit fee4f2c6 authored by Wei Yongjun's avatar Wei Yongjun Committed by Will Deacon

drivers: CCI: fix the error handle in cci_pmu_probe()

This patch fix the error handle of function cci_pmu_probe():
- using IS_ERR() instead of NULL test for the return value of
  devm_ioremap_resource() since it nerver return NULL.
- remove kfree() for devm_kzalloc allocated memory
- remove dev_warn() since devm_ioremap_resource() has error message
  already.
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent b91c8f28
...@@ -565,18 +565,9 @@ static int cci_pmu_probe(struct platform_device *pdev) ...@@ -565,18 +565,9 @@ static int cci_pmu_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_warn(&pdev->dev, "Failed to get mem resource\n");
ret = -EINVAL;
goto memalloc_err;
};
pmu->base = devm_ioremap_resource(&pdev->dev, res); pmu->base = devm_ioremap_resource(&pdev->dev, res);
if (!pmu->base) { if (IS_ERR(pmu->base))
dev_warn(&pdev->dev, "Failed to ioremap\n"); return -ENOMEM;
ret = -ENOMEM;
goto memalloc_err;
}
/* /*
* CCI PMU has 5 overflow signals - one per counter; but some may be tied * CCI PMU has 5 overflow signals - one per counter; but some may be tied
...@@ -601,22 +592,18 @@ static int cci_pmu_probe(struct platform_device *pdev) ...@@ -601,22 +592,18 @@ static int cci_pmu_probe(struct platform_device *pdev)
if (i < CCI_PMU_MAX_HW_EVENTS) { if (i < CCI_PMU_MAX_HW_EVENTS) {
dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n", dev_warn(&pdev->dev, "In-correct number of interrupts: %d, should be %d\n",
i, CCI_PMU_MAX_HW_EVENTS); i, CCI_PMU_MAX_HW_EVENTS);
ret = -EINVAL; return -EINVAL;
goto memalloc_err;
} }
pmu->port_ranges = port_range_by_rev(); pmu->port_ranges = port_range_by_rev();
if (!pmu->port_ranges) { if (!pmu->port_ranges) {
dev_warn(&pdev->dev, "CCI PMU version not supported\n"); dev_warn(&pdev->dev, "CCI PMU version not supported\n");
ret = -EINVAL; return -EINVAL;
goto memalloc_err;
} }
pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL); pmu->cci_pmu = devm_kzalloc(&pdev->dev, sizeof(*(pmu->cci_pmu)), GFP_KERNEL);
if (!pmu->cci_pmu) { if (!pmu->cci_pmu)
ret = -ENOMEM; return -ENOMEM;
goto memalloc_err;
}
pmu->hw_events.events = pmu->events; pmu->hw_events.events = pmu->events;
pmu->hw_events.used_mask = pmu->used_mask; pmu->hw_events.used_mask = pmu->used_mask;
...@@ -624,15 +611,9 @@ static int cci_pmu_probe(struct platform_device *pdev) ...@@ -624,15 +611,9 @@ static int cci_pmu_probe(struct platform_device *pdev)
ret = cci_pmu_init(pmu->cci_pmu, pdev); ret = cci_pmu_init(pmu->cci_pmu, pdev);
if (ret) if (ret)
goto pmuinit_err; return ret;
return 0; return 0;
pmuinit_err:
kfree(pmu->cci_pmu);
memalloc_err:
kfree(pmu);
return ret;
} }
static int cci_platform_probe(struct platform_device *pdev) static int cci_platform_probe(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment