All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: linux-kernel@vger.kernel.org, MyungJoo Ham <myungjoo.ham@samsung.com>
Subject: Re: [PATCH] extcon: max77693: Fix max77693_muic_probe error handling
Date: Thu, 04 Oct 2012 10:27:48 +0900	[thread overview]
Message-ID: <506CE614.30606@samsung.com> (raw)
In-Reply-To: <1349231038.6191.1.camel@phoenix>

On 10/03/2012 11:23 AM, Axel Lin wrote:

> Fix below issues:
> 1. If request_threaded_irq() fails, current code does not free all requested
>    irqs.
> 2. Add missing extcon_dev_unregister() in error path if failed to read revision
>    number.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/extcon/extcon-max77693.c |   12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
> index e0ed622..9928c63 100644
> --- a/drivers/extcon/extcon-max77693.c
> +++ b/drivers/extcon/extcon-max77693.c
> @@ -696,12 +696,8 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev)
>  				IRQF_ONESHOT, muic_irq->name, info);
>  		if (ret) {
>  			dev_err(&pdev->dev,
> -				"failed: irq request (IRQ: %d,"
> -				" error :%d)\n",
> +				"failed: irq request (IRQ: %d, error :%d)\n",
>  				muic_irq->irq, ret);
> -
> -			for (i = i - 1; i >= 0; i--)
> -				free_irq(muic_irq->virq, info);
>  			goto err_irq;
>  		}
>  	}
> @@ -726,7 +722,7 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev)
>  			MAX77693_MUIC_REG_ID, &id);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to read revision number\n");
> -		goto err_extcon;
> +		goto err_read_reg;
>  	}
>  	dev_info(info->dev, "device ID : 0x%x\n", id);
>  
> @@ -738,9 +734,13 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev)
>  
>  	return ret;
>  
> +err_read_reg:
> +	extcon_dev_unregister(info->edev);
>  err_extcon:
>  	kfree(info->edev);
>  err_irq:
> +	while (--i >= 0)
> +		free_irq(muic_irqs[i].virq, info);


This include possible error when 'i' variable may be used after
completed request_thread_irq() operation. I think the below patch
is appropriate because free_irq() function return NULL if first parameter
is unrequested irq.

err_irq:
+       for (i = 0; i < ARRAY_SIZE(muic_irqs); i++)
+               free_irq(muic_irqs[i].virq, info);

Thank you,
Chanwoo Choi

      reply	other threads:[~2012-10-04  1:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-03  2:23 [PATCH] extcon: max77693: Fix max77693_muic_probe error handling Axel Lin
2012-10-04  1:27 ` Chanwoo Choi [this message]

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=506CE614.30606@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=axel.lin@ingics.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    /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.