Hi,
On Mon, Aug 5, 2024 at 3:21 AM Jiri Slaby (SUSE) jirislaby@kernel.org wrote:
Coverity reports (as CID 1536978) that uart_poll_init() passes uninitialized pm_state to uart_change_pm(). It is in case the first 'if' takes the true branch (does "goto out;").
Fix this and simplify the function by simple guard(mutex). The code needs no labels after this at all. And it is pretty clear that the code has not fiddled with pm_state at that point.
Signed-off-by: Jiri Slaby (SUSE) jirislaby@kernel.org Fixes: 5e227ef2aa38 (serial: uart_poll_init() should power on the UART) Cc: stable@vger.kernel.org Cc: Douglas Anderson dianders@chromium.org Cc: Greg Kroah-Hartman gregkh@linuxfoundation.org
drivers/tty/serial/serial_core.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Thanks for the fix! Looks good.
Reviewed-by: Douglas Anderson dianders@chromium.org
NOTE: I'm happy to defer to others, but personally I'd consider breaking this into two changes: one that fixes the problem without using guard() (which should be pretty simple) and one that switches to guard(). The issue is that at the time the bug was introduced the guard() syntax didn't exist and that means backporting will be a bit of a pain.
Oh, though I guess maybe it doesn't matter since the bug was introduced in 6.4 and that's not an LTS kernel so nobody cares? ...and guard() is in 6.6, so maybe things are fine the way you have it.