[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VeZSU5i1k6W1dgE4kOW5wfRM-jJvmPvi8wCdqQeFVtRbQ@mail.gmail.com>
Date: Tue, 7 Jun 2022 12:15:08 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Tom Rix <trix@...hat.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Peter Hurley <peter@...leysoftware.com>,
"open list:SERIAL DRIVERS" <linux-serial@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
llvm@...ts.linux.dev
Subject: Re: [PATCH] serial: core: check if uart_get_info succeeds before using
On Sun, May 29, 2022 at 4:09 PM Tom Rix <trix@...hat.com> wrote:
>
> clang static analysis reports this representative issue
> drivers/tty/serial/serial_core.c:2818:9: warning: 3rd function call argument is an uninitialized value [core.CallAndMessage]
> return sprintf(buf, "%d\n", tmp.iomem_reg_shift);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> uart_get_info() is used the *show() functions. When uart_get_info() fails, what is reported
in the ?
> is garbage. So check if uart_get_info() succeeded.
...
> - uart_get_info(port, &tmp);
> + if (uart_get_info(port, &tmp))
> + return 0;
I don't think this is correct. If something fails we need to inform the caller.
I think more about
int ret;
ret = uart_get_info(...);
if (ret)
return ret;
But I haven't looked at the uart_get_info() implementation, so the
above might be wrong.
> return sprintf(buf, "%d\n", tmp.baud_base * 16);
Ditto for the rest.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists