lkml.org 
[lkml]   [2022]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] serial: core: check if uart_get_info succeeds before using
On Sun, May 29, 2022 at 4:09 PM Tom Rix <trix@redhat.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

\
 
 \ /
  Last update: 2022-06-07 12:16    [W:0.096 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site