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: <CAD-N9QWTP8DLtAN70Xxap+WhNUfh9ixfeDMuNaB2NnpFhuAN8A@mail.gmail.com>
Date:   Wed, 13 Oct 2021 13:21:09 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Appana Durga Kedareswara rao <appana.durga.rao@...inx.com>,
        Naga Sureshkumar Relli <naga.sureshkumar.relli@...inx.com>,
        Wolfgang Grandegger <wg@...ndegger.com>,
        Marc Kleine-Budde <mkl@...gutronix.de>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Michal Simek <michal.simek@...inx.com>
Cc:     linux-can@...r.kernel.org,
        "open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>,
        linux-arm-kernel@...ts.infradead.org,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] driver: net: can: delete napi if register_candev fails

On Wed, Oct 13, 2021 at 12:04 PM Dongliang Mu <mudongliangabcd@...il.com> wrote:
>
> If register_candev fails, xcan_probe does not clean the napi
> created by netif_napi_add.
>

It seems the netif_napi_del operation is done in the free_candev
(free_netdev precisely).

list_for_each_entry_safe(p, n, &dev->napi_list, dev_list)
          netif_napi_del(p);

And list_add_rcu(&napi->dev_list, &dev->napi_list) is done in the
netif_napi_add.

Therefore, I suggest removing "netif_napi_del" operation in the
xcan_remove to match probe and remove function.

> Fix this by adding error handling code to clean napi when
> register_candev fails.
>
> Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
> ---
>  drivers/net/can/xilinx_can.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
> index 3b883e607d8b..6ee0b5a8cdfc 100644
> --- a/drivers/net/can/xilinx_can.c
> +++ b/drivers/net/can/xilinx_can.c
> @@ -1807,7 +1807,7 @@ static int xcan_probe(struct platform_device *pdev)
>         ret = register_candev(ndev);
>         if (ret) {
>                 dev_err(&pdev->dev, "fail to register failed (err=%d)\n", ret);
> -               goto err_disableclks;
> +               goto err_del_napi;
>         }
>
>         devm_can_led_init(ndev);
> @@ -1825,6 +1825,8 @@ static int xcan_probe(struct platform_device *pdev)
>
>         return 0;
>
> +err_del_napi:
> +       netif_napi_del(&priv->napi);
>  err_disableclks:
>         pm_runtime_put(priv->dev);
>         pm_runtime_disable(&pdev->dev);
> --
> 2.25.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ