FAILED: patch "[PATCH] serial: don't use uninitialized value in uart_poll_init()" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x d0009a32c9e4e083358092f3c97e3c6e803a8930
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024100108-attention-muppet-0778@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
d0009a32c9e4 ("serial: don't use uninitialized value in uart_poll_init()") 788aeef392d2 ("tty: serial: kgdboc: Fix 8250_* kgdb over serial")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d0009a32c9e4e083358092f3c97e3c6e803a8930 Mon Sep 17 00:00:00 2001
From: "Jiri Slaby (SUSE)" <[email protected]>
Date: Mon, 5 Aug 2024 12:20:36 +0200
Subject: [PATCH] serial: don't use uninitialized value in uart_poll_init()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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.
drivers/tty/serial/serial_core.c +6 -7
@@ -2690,14 +2690,13 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options)int ret =0 ; tport = &state->port; -mutex_lock (&tport->mutex); + +guard (mutex)(&tport->mutex); port =uart_port_check (state);if (!port || port->type ==PORT_UNKNOWN || - !(port->ops->poll_get_char && port->ops->poll_put_char)) { - ret =-1 ; - goto out; - } + !(port->ops->poll_get_char && port->ops->poll_put_char)) +return -1 ; pm_state = state->pm_state;uart_change_pm (state,UART_PM_STATE_ON );
@@ -2717,10 +2716,10 @@ static int uart_poll_init(struct tty_driver *driver, int line, char *options) ret =uart_set_options (port,NULL , baud, parity, bits, flow);console_list_unlock (); } -out: +if (ret)uart_change_pm (state, pm_state); -mutex_unlock (&tport->mutex); +return ret; }