lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=MfmOTy6zU0v3gc6-d9zLpuzZaP9ChCajF=POmKhEQ+g_g@mail.gmail.com>
Date:   Mon, 18 Sep 2023 13:31:59 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     linus.walleij@...aro.org, andy@...nel.org, galak@...eaurora.org,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] gpio: tb10x: Fix an error handling path in tb10x_gpio_probe()

On Sat, Sep 16, 2023 at 5:10 PM Christophe JAILLET
<christophe.jaillet@...adoo.fr> wrote:
>
> Le 03/09/2023 à 19:02, Bartosz Golaszewski a écrit :
> > On Sun, Sep 3, 2023 at 8:13 AM Christophe JAILLET
> > <christophe.jaillet@...adoo.fr> wrote:
> >>
> >> If an error occurs after a successful irq_domain_add_linear() call, it
> >> should be undone by a corresponding irq_domain_remove(), as already done
> >> in the remove function.
> >>
> >> Fixes: c6ce2b6bffe5 ("gpio: add TB10x GPIO driver")
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> >> ---
> >>   drivers/gpio/gpio-tb10x.c | 6 +++++-
> >>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
> >> index 78f8790168ae..f96d260a4a19 100644
> >> --- a/drivers/gpio/gpio-tb10x.c
> >> +++ b/drivers/gpio/gpio-tb10x.c
> >> @@ -195,7 +195,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
> >>                                  handle_edge_irq, IRQ_NOREQUEST, IRQ_NOPROBE,
> >>                                  IRQ_GC_INIT_MASK_CACHE);
> >>                  if (ret)
> >> -                       return ret;
> >> +                       goto err_remove_domain;
> >>
> >>                  gc = tb10x_gpio->domain->gc->gc[0];
> >>                  gc->reg_base                         = tb10x_gpio->base;
> >> @@ -209,6 +209,10 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
> >>          }
> >>
> >>          return 0;
> >> +
> >> +err_remove_domain:
> >> +       irq_domain_remove(tb10x_gpio->domain);
> >> +       return ret;
> >>   }
> >>
> >>   static int tb10x_gpio_remove(struct platform_device *pdev)
> >> --
> >> 2.34.1
> >>
> >
> > That's not enough, you also need to dispose of all remaining mappings.
> > Please see drivers/gpio/gpiolib.c and how it handles the gpio_irq_chip
> > domain.
>
> Hi,
>
> you'll have to give me more explanation because I've not been able to
> find anything useful to me.
>

I should have expressed myself clearer. Your patch is correct and I
will queue it. But in your remove callback, you'll need to go through
the existing irq mappings and dispose of them before returning. Please
see gpiochip_irqchip_remove()[1]. You can send it as a follow-up.

Bart

[1] https://elixir.bootlin.com/linux/latest/source/drivers/gpio/gpiolib.c#L1725

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ