* [PATCH v2 1/1] pinctrl: mcp23s08: fix irq and irqchip setup order [not found] <20181002080646.10822-1-m.felsch@pengutronix.de> @ 2018-10-02 8:06 ` Marco Felsch 2018-10-03 1:24 ` Phil Reid 0 siblings, 1 reply; 2+ messages in thread From: Marco Felsch @ 2018-10-02 8:06 UTC (permalink / raw) To: linus.walleij Cc: linux-gpio, kernel, stable, Phil Reid, Jan Kundrát, Dmitry Mastykin, Sebastian Reichel Since 'commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' the irq request isn't the last devm_* allocation. Without a deeper look at the irq and testing this isn't a good solution. Since this driver relies on the devm mechanism, requesting a interrupt should be the last thing to avoid memory corruptions during unbinding. 'Commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' fixed the order for the interrupt-controller use case only. The mcp23s08_irq_setup() must be split into two to fix it for the interrupt-controller use case and to register the irq at last. So the irq will be freed first during unbind. Cc: stable@vger.kernel.org Cc: Phil Reid <preid@electromag.com.au> Cc: Jan Kundrát <jan.kundrat@cesnet.cz> Cc: Dmitry Mastykin <mastichi@gmail.com> Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Fixes: 82039d244f87 ("pinctrl: mcp23s08: add pinconf support") Fixes: 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order") Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- drivers/pinctrl/pinctrl-mcp23s08.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index 4a8a8efadefa..cf73a403d22d 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -636,6 +636,14 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) return err; } + return 0; +} + +static int mcp23s08_irqchip_setup(struct mcp23s08 *mcp) +{ + struct gpio_chip *chip = &mcp->chip; + int err; + err = gpiochip_irqchip_add_nested(chip, &mcp23s08_irq_chip, 0, @@ -912,7 +920,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, } if (mcp->irq && mcp->irq_controller) { - ret = mcp23s08_irq_setup(mcp); + ret = mcp23s08_irqchip_setup(mcp); if (ret) goto fail; } @@ -944,6 +952,9 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, goto fail; } + if (mcp->irq) + ret = mcp23s08_irq_setup(mcp); + fail: if (ret < 0) dev_dbg(dev, "can't setup chip %d, --> %d\n", addr, ret); -- 2.19.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] pinctrl: mcp23s08: fix irq and irqchip setup order 2018-10-02 8:06 ` [PATCH v2 1/1] pinctrl: mcp23s08: fix irq and irqchip setup order Marco Felsch @ 2018-10-03 1:24 ` Phil Reid 0 siblings, 0 replies; 2+ messages in thread From: Phil Reid @ 2018-10-03 1:24 UTC (permalink / raw) To: Marco Felsch, linus.walleij Cc: linux-gpio, kernel, stable, Jan Kundrát, Dmitry Mastykin, Sebastian Reichel On 2/10/2018 4:06 PM, Marco Felsch wrote: > Since 'commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' the > irq request isn't the last devm_* allocation. Without a deeper look at > the irq and testing this isn't a good solution. Since this driver relies > on the devm mechanism, requesting a interrupt should be the last thing > to avoid memory corruptions during unbinding. > > 'Commit 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order")' fixed the > order for the interrupt-controller use case only. The > mcp23s08_irq_setup() must be split into two to fix it for the > interrupt-controller use case and to register the irq at last. So the > irq will be freed first during unbind. > Tested with mcp23s18 with an irq. Tested-by: Phil Reid <preid@electromag.com.au> > Cc: stable@vger.kernel.org > Cc: Phil Reid <preid@electromag.com.au> > Cc: Jan Kundrát <jan.kundrat@cesnet.cz> > Cc: Dmitry Mastykin <mastichi@gmail.com> > Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk> > Fixes: 82039d244f87 ("pinctrl: mcp23s08: add pinconf support") > Fixes: 02e389e63e35 ("pinctrl: mcp23s08: fix irq setup order") > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> > --- > drivers/pinctrl/pinctrl-mcp23s08.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c > index 4a8a8efadefa..cf73a403d22d 100644 > --- a/drivers/pinctrl/pinctrl-mcp23s08.c > +++ b/drivers/pinctrl/pinctrl-mcp23s08.c > @@ -636,6 +636,14 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) > return err; > } > > + return 0; > +} > + > +static int mcp23s08_irqchip_setup(struct mcp23s08 *mcp) > +{ > + struct gpio_chip *chip = &mcp->chip; > + int err; > + > err = gpiochip_irqchip_add_nested(chip, > &mcp23s08_irq_chip, > 0, > @@ -912,7 +920,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, > } > > if (mcp->irq && mcp->irq_controller) { > - ret = mcp23s08_irq_setup(mcp); > + ret = mcp23s08_irqchip_setup(mcp); > if (ret) > goto fail; > } > @@ -944,6 +952,9 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, > goto fail; > } > > + if (mcp->irq) > + ret = mcp23s08_irq_setup(mcp); > + > fail: > if (ret < 0) > dev_dbg(dev, "can't setup chip %d, --> %d\n", addr, ret); > -- Regards Phil Reid ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-03 1:24 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20181002080646.10822-1-m.felsch@pengutronix.de> 2018-10-02 8:06 ` [PATCH v2 1/1] pinctrl: mcp23s08: fix irq and irqchip setup order Marco Felsch 2018-10-03 1:24 ` Phil Reid
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).