[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJO-fB_dSwuTp5XZ@smile.fi.intel.com>
Date: Wed, 6 Aug 2025 23:43:40 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Abinash Singh <abinashsinghlalotra@...il.com>
Cc: arnd@...db.de, gregkh@...uxfoundation.org, jirislaby@...nel.org,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
sunilvl@...tanamicro.com, u.kleine-koenig@...libre.com
Subject: Re: [PATCH v2 2/2] serial: 8250_platform: Reduce stack usage in
serial8250_probe_platform()
On Thu, Aug 07, 2025 at 01:40:47AM +0530, Abinash Singh wrote:
> The function serial8250_probe_platform() in 8250_platform.c triggered a
> frame size warning:
> drivers/tty/serial/8250/8250_platform.c: In function ‘serial8250_probe_platform.isra’:
> drivers/tty/serial/8250/8250_platform.c:201:1: warning: the frame size of 1184 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> This patch reduces the stack usage by dynamically allocating the
> `uart` structure using kzalloc(), rather than placing it on
> the stack. This eliminates the overflow warning and improves kernel
> robustness.
...
> - struct uart_8250_port uart;
> int ret, i, irqflag = 0;
> + struct uart_8250_port *uart = kzalloc(sizeof(*uart), GFP_KERNEL);
>
> - memset(&uart, 0, sizeof(uart));
> + if (!uart)
> + return -ENOMEM;
Missed __free and same comment as in previous patch. An rule of thumb: avoid
such a split in the future, try to have an assignment and followed up check go
together, it 's easier to maintain and less prone to subtle mistakes.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists