From: Libo Chen Date: Thu, 27 Jun 2013 23:50:56 +0000 (+1000) Subject: drivers/iommu/msm_iommu_dev.c: fix leak and clean up error paths X-Git-Tag: next-20130628~3^2~663 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1e9ba14dac9488d74cc5c45ce3056292f709d0b9;p=karo-tx-linux.git drivers/iommu/msm_iommu_dev.c: fix leak and clean up error paths Fix two obvious problems: 1. We have registered msm_iommu_driver first, and need unregister it when registered msm_iommu_ctx_driver fail 2. We don`t need to kfree drvdata before kzalloc successful. Signed-off-by: Libo Chen Acked-by: David Brown Cc: David Woodhouse Cc: James Hogan Signed-off-by: Andrew Morton --- diff --git a/drivers/iommu/msm_iommu_dev.c b/drivers/iommu/msm_iommu_dev.c index 9144a6beed92..63cdeb903d5c 100644 --- a/drivers/iommu/msm_iommu_dev.c +++ b/drivers/iommu/msm_iommu_dev.c @@ -294,22 +294,20 @@ static int msm_iommu_ctx_probe(struct platform_device *pdev) struct msm_iommu_ctx_drvdata *ctx_drvdata = NULL; int i, ret; if (!c || !pdev->dev.parent) { - ret = -EINVAL; - goto fail; + return -EINVAL; } drvdata = dev_get_drvdata(pdev->dev.parent); if (!drvdata) { - ret = -ENODEV; - goto fail; + return -ENODEV; } ctx_drvdata = kzalloc(sizeof(*ctx_drvdata), GFP_KERNEL); if (!ctx_drvdata) { - ret = -ENOMEM; - goto fail; + return -ENOMEM; } + ctx_drvdata->num = c->num; ctx_drvdata->pdev = pdev; @@ -403,6 +401,7 @@ static int __init msm_iommu_driver_init(void) ret = platform_driver_register(&msm_iommu_ctx_driver); if (ret != 0) { + platform_driver_unregister(&msm_iommu_driver); pr_err("Failed to register IOMMU context driver\n"); goto error; }