summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/serial_core.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2023-10-05 19:34:21 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-07 11:21:42 +0200
commitcfb5e0cece70b36bacbe8f888c096e6370a9c6ba (patch)
tree847911dc2e255e3a490684f4dda33b5b196ecbbf /drivers/tty/serial/serial_core.c
parent1f34e3defb5c0a038945795d2e01bbe9d9c05a64 (diff)
downloadlinux-stable-cfb5e0cece70b36bacbe8f888c096e6370a9c6ba.tar.gz
linux-stable-cfb5e0cece70b36bacbe8f888c096e6370a9c6ba.tar.bz2
linux-stable-cfb5e0cece70b36bacbe8f888c096e6370a9c6ba.zip
serial: initialize retinfo in uart_get_info()
If this check ever triggers static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) { uport = uart_port_check(state); if (!uport) goto out; then all those sysfs users will print stack contents to userspace. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Link: https://lore.kernel.org/r/967b9ef1-fb36-48bf-9e6a-1b99af24c052@p183 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/serial_core.c')
-rw-r--r--drivers/tty/serial/serial_core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 70bf2bec875c..be74d30cfa9e 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -775,6 +775,9 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
struct uart_port *uport;
int ret = -ENODEV;
+ /* Initialize structure in case we error out later to prevent any stack info leakage. */
+ *retinfo = (struct serial_struct){};
+
/*
* Ensure the state we copy is consistent and no hardware changes
* occur as we go