linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Reid <preid@electromag.com.au>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Linus Walleij <linus.walleij@linaro.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH 1/2] gpio: em: remove the gpiochip before removing the irq domain
Date: Wed, 10 Jul 2019 17:37:24 +0800	[thread overview]
Message-ID: <510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au> (raw)
In-Reply-To: <20190710090852.9239-1-brgl@bgdev.pl>

G'day Bartosz,

One comment below

On 10/07/2019 17:08, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> In commit 8764c4ca5049 ("gpio: em: use the managed version of
> gpiochip_add_data()") we implicitly altered the ordering of resource
> freeing: since gpiochip_remove() calls gpiochip_irqchip_remove()
> internally, we now can potentially use the irq_domain after it was
> destroyed in the remove() callback (as devm resources are freed after
> remove() has returned).
> 
> Use devm_add_action() to keep the ordering right and entirely kill
> the remove() callback in the driver.
> 
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Fixes: 8764c4ca5049 ("gpio: em: use the managed version of gpiochip_add_data()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>   drivers/gpio/gpio-em.c | 35 +++++++++++++++++------------------
>   1 file changed, 17 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
> index b6af705a4e5f..c88028ac66f2 100644
> --- a/drivers/gpio/gpio-em.c
> +++ b/drivers/gpio/gpio-em.c
> @@ -259,6 +259,13 @@ static const struct irq_domain_ops em_gio_irq_domain_ops = {
>   	.xlate	= irq_domain_xlate_twocell,
>   };
>   
> +static void em_gio_irq_domain_remove(void *data)
> +{
> +	struct irq_domain *domain = data;
> +
> +	irq_domain_remove(domain);
> +}
> +
>   static int em_gio_probe(struct platform_device *pdev)
>   {
>   	struct em_gio_priv *p;
> @@ -333,39 +340,32 @@ static int em_gio_probe(struct platform_device *pdev)
>   		return -ENXIO;
>   	}
>   
> +	ret = devm_add_action(&pdev->dev,
> +			      em_gio_irq_domain_remove, p->irq_domain);

Could devm_add_action_or_reset be used?

> +	if (ret) {
> +		irq_domain_remove(p->irq_domain);
> +		return ret;
> +	}
> +
>   	if (devm_request_irq(&pdev->dev, irq[0]->start,
>   			     em_gio_irq_handler, 0, name, p)) {
>   		dev_err(&pdev->dev, "failed to request low IRQ\n");
> -		ret = -ENOENT;
> -		goto err1;
> +		return -ENOENT;
>   	}
>   
>   	if (devm_request_irq(&pdev->dev, irq[1]->start,
>   			     em_gio_irq_handler, 0, name, p)) {
>   		dev_err(&pdev->dev, "failed to request high IRQ\n");
> -		ret = -ENOENT;
> -		goto err1;
> +		return -ENOENT;
>   	}
>   
>   	ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p);
>   	if (ret) {
>   		dev_err(&pdev->dev, "failed to add GPIO controller\n");
> -		goto err1;
> +		return ret;
>   	}
>   
>   	return 0;
> -
> -err1:
> -	irq_domain_remove(p->irq_domain);
> -	return ret;
> -}
> -
> -static int em_gio_remove(struct platform_device *pdev)
> -{
> -	struct em_gio_priv *p = platform_get_drvdata(pdev);
> -
> -	irq_domain_remove(p->irq_domain);
> -	return 0;
>   }
>   
>   static const struct of_device_id em_gio_dt_ids[] = {
> @@ -376,7 +376,6 @@ MODULE_DEVICE_TABLE(of, em_gio_dt_ids);
>   
>   static struct platform_driver em_gio_device_driver = {
>   	.probe		= em_gio_probe,
> -	.remove		= em_gio_remove,
>   	.driver		= {
>   		.name	= "em_gio",
>   		.of_match_table = em_gio_dt_ids,
> 


-- 
Regards
Phil Reid


  parent reply	other threads:[~2019-07-10  9:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10  9:08 [PATCH 1/2] gpio: em: remove the gpiochip before removing the irq domain Bartosz Golaszewski
2019-07-10  9:08 ` [PATCH 2/2] gpio: em: use a helper variable for &pdev->dev Bartosz Golaszewski
2019-07-28 23:10   ` Linus Walleij
2019-07-10  9:37 ` Phil Reid [this message]
2019-07-10  9:47   ` [PATCH 1/2] gpio: em: remove the gpiochip before removing the irq domain Bartosz Golaszewski
2019-07-10 10:13   ` Geert Uytterhoeven

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=510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au \
    --to=preid@electromag.com.au \
    --cc=bgolaszewski@baylibre.com \
    --cc=brgl@bgdev.pl \
    --cc=geert@linux-m68k.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).