Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Rob Jones <rob.jones@codethink.co.uk>
Cc: linux-gpio@vger.kernel.org, broonie@opensource.wolfsonmicro.com,
	ext-roger.quadros@nokia.com
Subject: Re: [PATCH] regulator: gpio-regulator: use devm_*
Date: Thu, 22 May 2014 17:24:47 +0200	[thread overview]
Message-ID: <3643522.fIroKZpKff@phil> (raw)
In-Reply-To: <1400770266-7276-1-git-send-email-rob.jones@codethink.co.uk>

Hi Rob,

this is racy.

The deallocation of devm_* stuff is done _after_ the driver _remove callback 
ran, where in the gpio_regulator case it would already have done at least

>  	gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
> 
>  	kfree(drvdata->states);

before the regulator gets deregistered, thus producing a race condition.


Also Mark's mail address is
	Mark Brown <broonie@kernel.org>
and
	linux-kernel@vger.kernel.org
should be included as well.


Heiko


Am Donnerstag, 22. Mai 2014, 15:51:06 schrieb Rob Jones:
> Use devm_regulator_register in probe/remove.
> 
> Reviewed-by: Ian Molton <ian.molton@codethink.co.uk>
> Signed-off-by: Rob Jones <rob.jones@codethink.co.uk>
> ---
>  drivers/regulator/gpio-regulator.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/regulator/gpio-regulator.c
> b/drivers/regulator/gpio-regulator.c index 989b23b..994a050 100644
> --- a/drivers/regulator/gpio-regulator.c
> +++ b/drivers/regulator/gpio-regulator.c
> @@ -337,7 +337,7 @@ static int gpio_regulator_probe(struct platform_device
> *pdev) cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
>  	}
> 
> -	drvdata->dev = regulator_register(&drvdata->desc, &cfg);
> +	drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, &cfg);
>  	if (IS_ERR(drvdata->dev)) {
>  		ret = PTR_ERR(drvdata->dev);
>  		dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
> @@ -364,8 +364,6 @@ static int gpio_regulator_remove(struct platform_device
> *pdev) {
>  	struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev);
> 
> -	regulator_unregister(drvdata->dev);
> -
>  	gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
> 
>  	kfree(drvdata->states);


      reply	other threads:[~2014-05-22 15:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 14:51 [PATCH] regulator: gpio-regulator: use devm_* Rob Jones
2014-05-22 15:24 ` Heiko Stübner [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=3643522.fIroKZpKff@phil \
    --to=heiko@sntech.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=ext-roger.quadros@nokia.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=rob.jones@codethink.co.uk \
    /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