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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPDyKFoS60VjCSAqSBmtjpxGrVefHT4xt+O5qzsjBYRmQsJ8OA@mail.gmail.com>
Date:   Tue, 24 Nov 2020 11:56:44 +0100
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>
Cc:     Russell King <linux@...linux.org.uk>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        Linus Walleij <linus.walleij@...aro.org>,
        Rob Herring <robh@...nel.org>,
        Sascha Hauer <kernel@...gutronix.de>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/4] amba: Fix resource leak for drivers without .remove

On Tue, 24 Nov 2020 at 11:33, Uwe Kleine-König
<u.kleine-koenig@...gutronix.de> wrote:
>
> Consider an amba driver with a .probe but without a .remove callback (e.g.
> pl061_gpio_driver). The function amba_probe() is called to bind a device
> and so dev_pm_domain_attach() and others are called. As there is no remove
> callback amba_remove() isn't called at unbind time however and so calling
> dev_pm_domain_detach() is missed and the pm domain keeps active.
>
> To fix this always use the core driver callbacks and handle missing amba
> callbacks there. For probe refuse registration as a driver without probe
> doesn't make sense.
>
> Fixes: 7cfe249475fd ("ARM: AMBA: Add pclk support to AMBA bus infrastructure")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>

Reviewed-by: Ulf Hansson <ulf.hansson@...aro.org>


> ---
>  drivers/amba/bus.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 8658e0533b67..8c4a42df47c6 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -300,10 +300,11 @@ static int amba_remove(struct device *dev)
>  {
>         struct amba_device *pcdev = to_amba_device(dev);
>         struct amba_driver *drv = to_amba_driver(dev->driver);
> -       int ret;
> +       int ret = 0;
>
>         pm_runtime_get_sync(dev);
> -       ret = drv->remove(pcdev);
> +       if (drv->remove)
> +               ret = drv->remove(pcdev);
>         pm_runtime_put_noidle(dev);
>
>         /* Undo the runtime PM settings in amba_probe() */
> @@ -320,7 +321,9 @@ static int amba_remove(struct device *dev)
>  static void amba_shutdown(struct device *dev)
>  {
>         struct amba_driver *drv = to_amba_driver(dev->driver);
> -       drv->shutdown(to_amba_device(dev));
> +
> +       if (drv->shutdown)
> +               drv->shutdown(to_amba_device(dev));
>  }
>
>  /**
> @@ -333,12 +336,13 @@ static void amba_shutdown(struct device *dev)
>   */
>  int amba_driver_register(struct amba_driver *drv)
>  {
> -       drv->drv.bus = &amba_bustype;
> +       if (!drv->probe)
> +               return -EINVAL;
>
> -#define SETFN(fn)      if (drv->fn) drv->drv.fn = amba_##fn
> -       SETFN(probe);
> -       SETFN(remove);
> -       SETFN(shutdown);
> +       drv->drv.bus = &amba_bustype;
> +       drv->drv.probe = amba_probe;
> +       drv->drv.remove = amba_remove;
> +       drv->drv.shutdown = amba_shutdown;
>
>         return driver_register(&drv->drv);
>  }
> --
> 2.29.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ