diff mbox

mfd: db8500-prcmu: check return of devm_ioremap for error

Message ID 1414660895-29255-1-git-send-email-pramod.gurav@smartplayin.com
State Accepted
Commit 51a7e02bb629498c32915881ed4fb61ef778282a
Headers show

Commit Message

Pramod Gurav Oct. 30, 2014, 9:21 a.m. UTC
Error check around return value of devm_ioremap is missing. Add the same
to avoid NULL pointer dereference.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
 drivers/mfd/db8500-prcmu.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Linus Walleij Oct. 31, 2014, 9:11 p.m. UTC | #1
On Thu, Oct 30, 2014 at 10:21 AM, Pramod Gurav
<pramod.gurav@smartplayin.com> wrote:

> Error check around return value of devm_ioremap is missing. Add the same
> to avoid NULL pointer dereference.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Lee Jones Nov. 3, 2014, 4:05 p.m. UTC | #2
On Thu, 30 Oct 2014, Pramod Gurav wrote:

> Error check around return value of devm_ioremap is missing. Add the same
> to avoid NULL pointer dereference.
> 
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
>  drivers/mfd/db8500-prcmu.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
> index 193cf16..89ae8bf 100644
> --- a/drivers/mfd/db8500-prcmu.c
> +++ b/drivers/mfd/db8500-prcmu.c
> @@ -3167,6 +3167,11 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
>  	}
>  	tcdm_base = devm_ioremap(&pdev->dev, res->start,
>  			resource_size(res));
> +	if (!tcdm_base) {
> +		dev_err(&pdev->dev,
> +			"failed to ioremap prcmu-tcdm register memory\n");
> +		return -ENOENT;

No such file or directory?  I think not.

Changed to -ENOMEM and applied with Linus' Ack.

> +	}
>  
>  	/* Clean up the mailbox interrupts after pre-kernel code. */
>  	writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);
Lee Jones Nov. 3, 2014, 4:45 p.m. UTC | #3
On Mon, 03 Nov 2014, Lee Jones wrote:

> On Thu, 30 Oct 2014, Pramod Gurav wrote:
> 
> > Error check around return value of devm_ioremap is missing. Add the same
> > to avoid NULL pointer dereference.
> > 
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> > ---
> >  drivers/mfd/db8500-prcmu.c |    5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
> > index 193cf16..89ae8bf 100644
> > --- a/drivers/mfd/db8500-prcmu.c
> > +++ b/drivers/mfd/db8500-prcmu.c
> > @@ -3167,6 +3167,11 @@ static int db8500_prcmu_probe(struct platform_device *pdev)
> >  	}
> >  	tcdm_base = devm_ioremap(&pdev->dev, res->start,
> >  			resource_size(res));
> > +	if (!tcdm_base) {
> > +		dev_err(&pdev->dev,
> > +			"failed to ioremap prcmu-tcdm register memory\n");
> > +		return -ENOENT;
> 
> No such file or directory?  I think not.
> 
> Changed to -ENOMEM and applied with Linus' Ack.

Slight change of plan, as it looks like all of the return paths were
bogus.  Patch sent instead.

> > +	}
> >  
> >  	/* Clean up the mailbox interrupts after pre-kernel code. */
> >  	writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);
>
diff mbox

Patch

diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c
index 193cf16..89ae8bf 100644
--- a/drivers/mfd/db8500-prcmu.c
+++ b/drivers/mfd/db8500-prcmu.c
@@ -3167,6 +3167,11 @@  static int db8500_prcmu_probe(struct platform_device *pdev)
 	}
 	tcdm_base = devm_ioremap(&pdev->dev, res->start,
 			resource_size(res));
+	if (!tcdm_base) {
+		dev_err(&pdev->dev,
+			"failed to ioremap prcmu-tcdm register memory\n");
+		return -ENOENT;
+	}
 
 	/* Clean up the mailbox interrupts after pre-kernel code. */
 	writel(ALL_MBOX_BITS, PRCM_ARM_IT1_CLR);