2022-09-17 03:08:25

by Yang Yingliang

[permalink] [raw]
Subject: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
in error path.

Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
Signed-off-by: Yang Yingliang <[email protected]>
---
v2:
move alloc_ordered_workqueue() after ocelot_pinctrl_register().
---
drivers/pinctrl/pinctrl-ocelot.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index d9c0184c077f..c672bc2a4df5 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -2065,10 +2065,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
if (!info->desc)
return -ENOMEM;

- info->wq = alloc_ordered_workqueue("ocelot_ordered", 0);
- if (!info->wq)
- return -ENOMEM;
-
info->pincfg_data = &data->pincfg_data;

reset = devm_reset_control_get_optional_shared(dev, "switch");
@@ -2107,9 +2103,15 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
if (ret)
return ret;

+ info->wq = alloc_ordered_workqueue("ocelot_ordered", 0);
+ if (!info->wq)
+ return -ENOMEM;
+
ret = ocelot_gpiochip_register(pdev, info);
- if (ret)
+ if (ret) {
+ destroy_workqueue(info->wq);
return ret;
+ }

dev_info(dev, "driver registered\n");

--
2.25.1


2022-09-17 09:08:11

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

Sat, Sep 17, 2022 at 10:46:33AM +0800, Yang Yingliang kirjoitti:
> Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> in error path.
>
> Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> Signed-off-by: Yang Yingliang <[email protected]>
> ---
> v2:
> move alloc_ordered_workqueue() after ocelot_pinctrl_register().

Why? What will happen if user space start using pins before workqueue is allocated?

If you really want to have it correct, you need either drop all devm_ calls
after allocating workqueue, or wrap destroying into devm.

--
With Best Regards,
Andy Shevchenko


2022-10-04 07:21:36

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

On Sat, Sep 17, 2022 at 4:39 AM Yang Yingliang <[email protected]> wrote:

> Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> in error path.
>
> Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> Signed-off-by: Yang Yingliang <[email protected]>
> ---
> v2:
> move alloc_ordered_workqueue() after ocelot_pinctrl_register().

Horatiu does this v2 look like you want it? Reviewed-by?

Yours,
Linus Walleij

2022-10-04 09:25:12

by Horatiu Vultur

[permalink] [raw]
Subject: Re: [PATCH -next v2 1/2] pinctrl: ocelot: add missing destroy_workqueue() in error path in ocelot_pinctrl_probe()

The 10/04/2022 09:09, Linus Walleij wrote:

Hi Linus,

>
> On Sat, Sep 17, 2022 at 4:39 AM Yang Yingliang <[email protected]> wrote:
>
> > Add the missing destroy_workqueue() before return from ocelot_pinctrl_probe()
> > in error path.
> >
> > Fixes: c297561bc98a ("pinctrl: ocelot: Fix interrupt controller")
> > Signed-off-by: Yang Yingliang <[email protected]>
> > ---
> > v2:
> > move alloc_ordered_workqueue() after ocelot_pinctrl_register().
>
> Horatiu does this v2 look like you want it? Reviewed-by?

I have noticed that Yang has sent another version (v3)[1] where he makes
uses of devm_add_action_or_reset.

[1] https://lore.kernel.org/all/[email protected]/T/

>
> Yours,
> Linus Walleij

--
/Horatiu