public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Stephen Warren <swarren@nvidia.com>,
	Anmar Oueja <anmar.oueja@linaro.org>,
	Lee Jones <lee.jones@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 4/4] pinctrl/abx500: destroy mutex if returning early due to error
Date: Wed, 30 Jan 2013 13:10:29 -0700	[thread overview]
Message-ID: <51097E35.6080100@wwwdotorg.org> (raw)
In-Reply-To: <1359574822-15729-1-git-send-email-linus.walleij@stericsson.com>

On 01/30/2013 12:40 PM, Linus Walleij wrote:
> From: Lee Jones <lee.jones@linaro.org>
> 
> Current failure path neglects to mutex_destroy() before returning
> an error due to an invalid parameter or an error received from
> gpiochip_add(). This patch aims to remedy that behaviour.

> diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c

> @@ -1155,11 +1155,13 @@ static int abx500_gpio_probe(struct platform_device *pdev)
>  	default:
>  		dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n",
>  				(int) platid->driver_data);
> +		mutex_destroy(&pct->lock);
>  		return -EINVAL;

Especially given there's already a label out_free which performs this
mutex_destroy(), those last two lines would be better as:

ret = -EINVAL;
goto out_free;

>  	}
>  
>  	if (!pct->soc) {
>  		dev_err(&pdev->dev, "Invalid SOC data\n");
> +		mutex_destroy(&pct->lock);
>  		return -EINVAL;

Same there.

>  	}
>  
> @@ -1176,6 +1178,7 @@ static int abx500_gpio_probe(struct platform_device *pdev)
>  	ret = gpiochip_add(&pct->chip);
>  	if (ret) {
>  		dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
> +		mutex_destroy(&pct->lock);
>  		goto out_rem_irq;

And here, just change the goto target to out_free rather than adding the
mutex_destroy() call.


  reply	other threads:[~2013-01-30 20:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30 19:40 [PATCH 4/4] pinctrl/abx500: destroy mutex if returning early due to error Linus Walleij
2013-01-30 20:10 ` Stephen Warren [this message]
2013-01-31  8:01   ` Lee Jones
2013-01-31 17:28     ` Stephen Warren
2013-01-31 17:45       ` Lee Jones

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=51097E35.6080100@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=anmar.oueja@linaro.org \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swarren@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox