All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stepan Moskovchenko <stepanm@codeaurora.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm: mach-msm: fix error handling in msm_iommu_probe()
Date: Mon, 18 Oct 2010 19:32:13 +0000	[thread overview]
Message-ID: <4CBCA0BD.7060609@codeaurora.org> (raw)
In-Reply-To: <1287327097-9025-1-git-send-email-segooon@gmail.com>

  On 10/17/2010 7:51 AM, Vasiliy Kulikov wrote:
> msm_iommu_probe() didn't free mem_region and mapped IO.
> Also if request_mem_region() failed then error handling
> code dereferenced NULL pointer.
>
> Signed-off-by: Vasiliy Kulikov<segooon@gmail.com>
> ---
>   arch/arm/mach-msm/iommu_dev.c |   22 +++++++++++++---------
>   1 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-msm/iommu_dev.c b/arch/arm/mach-msm/iommu_dev.c
> index c33ae78..9019cee 100644
> --- a/arch/arm/mach-msm/iommu_dev.c
> +++ b/arch/arm/mach-msm/iommu_dev.c
> @@ -128,7 +128,7 @@ static void msm_iommu_reset(void __iomem *base)
>
>   static int msm_iommu_probe(struct platform_device *pdev)
>   {
> -	struct resource *r;
> +	struct resource *r, *r2;
>   	struct clk *iommu_clk;
>   	struct msm_iommu_drvdata *drvdata;
>   	struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data;
> @@ -183,27 +183,27 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   		len = r->end - r->start + 1;
>
> -		r = request_mem_region(r->start, len, r->name);
> -		if (!r) {
> +		r2 = request_mem_region(r->start, len, r->name);
> +		if (!r2) {
>   			pr_err("Could not request memory region: "
>   			"start=%p, len=%d\n", (void *) r->start, len);
>   			ret = -EBUSY;
>   			goto fail;
>   		}
>
> -		regs_base = ioremap(r->start, len);
> +		regs_base = ioremap(r2->start, len);
>
>   		if (!regs_base) {
>   			pr_err("Could not ioremap: start=%p, len=%d\n",
> -				 (void *) r->start, len);
> +				 (void *) r2->start, len);
>   			ret = -EBUSY;
> -			goto fail;
> +			goto fail_mem;
>   		}
>
>   		irq = platform_get_irq_byname(pdev, "secure_irq");
>   		if (irq<  0) {
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		mb();
> @@ -211,14 +211,14 @@ static int msm_iommu_probe(struct platform_device *pdev)
>   		if (GET_IDR(regs_base) = 0) {
>   			pr_err("Invalid IDR value detected\n");
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		ret = request_irq(irq, msm_iommu_fault_handler, 0,
>   				"msm_iommu_secure_irpt_handler", drvdata);
>   		if (ret) {
>   			pr_err("Request IRQ %d failed with ret=%d\n", irq, ret);
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		msm_iommu_reset(regs_base);
> @@ -237,6 +237,10 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   	return 0;
>
> +fail_io:
> +	iounmap(regs_base);
> +fail_mem:
> +	release_mem_region(r->start, len);
>   fail:
>   	kfree(drvdata);
>   	return ret;

Tested on hardware. Looks good. Thanks!

Acked-by: Stepan Moskovchenko <stepanm@codeaurora.org>

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.




WARNING: multiple messages have this Message-ID (diff)
From: Stepan Moskovchenko <stepanm@codeaurora.org>
To: Vasiliy Kulikov <segooon@gmail.com>
Cc: kernel-janitors@vger.kernel.org,
	David Brown <davidb@codeaurora.org>,
	Daniel Walker <dwalker@codeaurora.org>,
	Bryan Huntsman <bryanh@codeaurora.org>,
	Russell King <linux@arm.linux.org.uk>,
	linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm: mach-msm: fix error handling in msm_iommu_probe()
Date: Mon, 18 Oct 2010 12:32:13 -0700	[thread overview]
Message-ID: <4CBCA0BD.7060609@codeaurora.org> (raw)
In-Reply-To: <1287327097-9025-1-git-send-email-segooon@gmail.com>

  On 10/17/2010 7:51 AM, Vasiliy Kulikov wrote:
> msm_iommu_probe() didn't free mem_region and mapped IO.
> Also if request_mem_region() failed then error handling
> code dereferenced NULL pointer.
>
> Signed-off-by: Vasiliy Kulikov<segooon@gmail.com>
> ---
>   arch/arm/mach-msm/iommu_dev.c |   22 +++++++++++++---------
>   1 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-msm/iommu_dev.c b/arch/arm/mach-msm/iommu_dev.c
> index c33ae78..9019cee 100644
> --- a/arch/arm/mach-msm/iommu_dev.c
> +++ b/arch/arm/mach-msm/iommu_dev.c
> @@ -128,7 +128,7 @@ static void msm_iommu_reset(void __iomem *base)
>
>   static int msm_iommu_probe(struct platform_device *pdev)
>   {
> -	struct resource *r;
> +	struct resource *r, *r2;
>   	struct clk *iommu_clk;
>   	struct msm_iommu_drvdata *drvdata;
>   	struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data;
> @@ -183,27 +183,27 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   		len = r->end - r->start + 1;
>
> -		r = request_mem_region(r->start, len, r->name);
> -		if (!r) {
> +		r2 = request_mem_region(r->start, len, r->name);
> +		if (!r2) {
>   			pr_err("Could not request memory region: "
>   			"start=%p, len=%d\n", (void *) r->start, len);
>   			ret = -EBUSY;
>   			goto fail;
>   		}
>
> -		regs_base = ioremap(r->start, len);
> +		regs_base = ioremap(r2->start, len);
>
>   		if (!regs_base) {
>   			pr_err("Could not ioremap: start=%p, len=%d\n",
> -				 (void *) r->start, len);
> +				 (void *) r2->start, len);
>   			ret = -EBUSY;
> -			goto fail;
> +			goto fail_mem;
>   		}
>
>   		irq = platform_get_irq_byname(pdev, "secure_irq");
>   		if (irq<  0) {
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		mb();
> @@ -211,14 +211,14 @@ static int msm_iommu_probe(struct platform_device *pdev)
>   		if (GET_IDR(regs_base) == 0) {
>   			pr_err("Invalid IDR value detected\n");
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		ret = request_irq(irq, msm_iommu_fault_handler, 0,
>   				"msm_iommu_secure_irpt_handler", drvdata);
>   		if (ret) {
>   			pr_err("Request IRQ %d failed with ret=%d\n", irq, ret);
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		msm_iommu_reset(regs_base);
> @@ -237,6 +237,10 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   	return 0;
>
> +fail_io:
> +	iounmap(regs_base);
> +fail_mem:
> +	release_mem_region(r->start, len);
>   fail:
>   	kfree(drvdata);
>   	return ret;

Tested on hardware. Looks good. Thanks!

Acked-by: Stepan Moskovchenko <stepanm@codeaurora.org>

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.




WARNING: multiple messages have this Message-ID (diff)
From: stepanm@codeaurora.org (Stepan Moskovchenko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: mach-msm: fix error handling in msm_iommu_probe()
Date: Mon, 18 Oct 2010 12:32:13 -0700	[thread overview]
Message-ID: <4CBCA0BD.7060609@codeaurora.org> (raw)
In-Reply-To: <1287327097-9025-1-git-send-email-segooon@gmail.com>

  On 10/17/2010 7:51 AM, Vasiliy Kulikov wrote:
> msm_iommu_probe() didn't free mem_region and mapped IO.
> Also if request_mem_region() failed then error handling
> code dereferenced NULL pointer.
>
> Signed-off-by: Vasiliy Kulikov<segooon@gmail.com>
> ---
>   arch/arm/mach-msm/iommu_dev.c |   22 +++++++++++++---------
>   1 files changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/mach-msm/iommu_dev.c b/arch/arm/mach-msm/iommu_dev.c
> index c33ae78..9019cee 100644
> --- a/arch/arm/mach-msm/iommu_dev.c
> +++ b/arch/arm/mach-msm/iommu_dev.c
> @@ -128,7 +128,7 @@ static void msm_iommu_reset(void __iomem *base)
>
>   static int msm_iommu_probe(struct platform_device *pdev)
>   {
> -	struct resource *r;
> +	struct resource *r, *r2;
>   	struct clk *iommu_clk;
>   	struct msm_iommu_drvdata *drvdata;
>   	struct msm_iommu_dev *iommu_dev = pdev->dev.platform_data;
> @@ -183,27 +183,27 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   		len = r->end - r->start + 1;
>
> -		r = request_mem_region(r->start, len, r->name);
> -		if (!r) {
> +		r2 = request_mem_region(r->start, len, r->name);
> +		if (!r2) {
>   			pr_err("Could not request memory region: "
>   			"start=%p, len=%d\n", (void *) r->start, len);
>   			ret = -EBUSY;
>   			goto fail;
>   		}
>
> -		regs_base = ioremap(r->start, len);
> +		regs_base = ioremap(r2->start, len);
>
>   		if (!regs_base) {
>   			pr_err("Could not ioremap: start=%p, len=%d\n",
> -				 (void *) r->start, len);
> +				 (void *) r2->start, len);
>   			ret = -EBUSY;
> -			goto fail;
> +			goto fail_mem;
>   		}
>
>   		irq = platform_get_irq_byname(pdev, "secure_irq");
>   		if (irq<  0) {
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		mb();
> @@ -211,14 +211,14 @@ static int msm_iommu_probe(struct platform_device *pdev)
>   		if (GET_IDR(regs_base) == 0) {
>   			pr_err("Invalid IDR value detected\n");
>   			ret = -ENODEV;
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		ret = request_irq(irq, msm_iommu_fault_handler, 0,
>   				"msm_iommu_secure_irpt_handler", drvdata);
>   		if (ret) {
>   			pr_err("Request IRQ %d failed with ret=%d\n", irq, ret);
> -			goto fail;
> +			goto fail_io;
>   		}
>
>   		msm_iommu_reset(regs_base);
> @@ -237,6 +237,10 @@ static int msm_iommu_probe(struct platform_device *pdev)
>
>   	return 0;
>
> +fail_io:
> +	iounmap(regs_base);
> +fail_mem:
> +	release_mem_region(r->start, len);
>   fail:
>   	kfree(drvdata);
>   	return ret;

Tested on hardware. Looks good. Thanks!

Acked-by: Stepan Moskovchenko <stepanm@codeaurora.org>

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  reply	other threads:[~2010-10-18 19:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-17 14:51 [PATCH] arm: mach-msm: fix error handling in msm_iommu_probe() Vasiliy Kulikov
2010-10-17 14:51 ` Vasiliy Kulikov
2010-10-17 14:51 ` Vasiliy Kulikov
2010-10-18 19:32 ` Stepan Moskovchenko [this message]
2010-10-18 19:32   ` Stepan Moskovchenko
2010-10-18 19:32   ` Stepan Moskovchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CBCA0BD.7060609@codeaurora.org \
    --to=stepanm@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.