Re: [PATCH] serial: core: check if uart_get_info succeeds before using

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 29, 2022 at 4:09 PM Tom Rix <trix@xxxxxxxxxx> 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



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux