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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAL_JsqLR_REJWVn_dO8R4ngkrqL=E_ksNr=jS0qRmdpmAaD8hQ@mail.gmail.com>
Date:   Thu, 27 Apr 2023 16:59:54 -0500
From:   Rob Herring <robh@...nel.org>
To:     Ke Zhang <m202171830@...t.edu.cn>
Cc:     Vineet Gupta <vgupta@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        hust-os-kernel-patches@...glegroups.com,
        Dongliang Mu <dzm91@...t.edu.cn>,
        Vineet Gupta <Vineet.Gupta1@...opsys.com>,
        linux-snps-arc@...ts.infradead.org, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] serial: arc_uart: fix of_iomap leak in `arc_serial_probe`

On Tue, Apr 25, 2023 at 8:27 PM Ke Zhang <m202171830@...t.edu.cn> wrote:
>
> Smatch reports:
>
> drivers/tty/serial/arc_uart.c:631 arc_serial_probe() warn:
> 'port->membase' from of_iomap() not released on lines: 631.
>
> In arc_serial_probe(), if uart_add_one_port() fails,
> port->membase is not released, which would cause a resource leak.
>
> To fix this, I replace of_iomap with devm_of_iomap.

How about use devm_platform_ioremap_resource() instead (or any ioremap
variant) as that is preferred over of_iomap().

Rob

>
> Fixes: 8dbe1d5e09a7 ("serial/arc: inline the probe helper")
> Signed-off-by: Ke Zhang <m202171830@...t.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
> ---
> This issue is found by static analysis and remains untested.
> ---
>  drivers/tty/serial/arc_uart.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
> index 59e25f2b6632..be1f3c379382 100644
> --- a/drivers/tty/serial/arc_uart.c
> +++ b/drivers/tty/serial/arc_uart.c
> @@ -606,10 +606,11 @@ static int arc_serial_probe(struct platform_device *pdev)
>         }
>         uart->baud = val;
>
> -       port->membase = of_iomap(np, 0);
> -       if (!port->membase)
> +       port->membase = devm_of_iomap(&pdev->dev, np, 0, NULL);
> +       if (IS_ERR(port->membase)) {
>                 /* No point of dev_err since UART itself is hosed here */
>                 return -ENXIO;

If an errno was returned, you should return that errno and not a different one.

Rob

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ