[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJKDCjFyei1lRYxk@smile.fi.intel.com>
Date: Wed, 6 Aug 2025 01:17:46 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Abinash Singh <abinashsinghlalotra@...il.com>
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org,
sunilvl@...tanamicro.com, arnd@...db.de,
u.kleine-koenig@...libre.com, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org
Subject: Re: [RFC PATCH 1/2] tty: serial/8250: Fix build warning in
serial8250_probe_acpi()
On Wed, Aug 06, 2025 at 01:21:54AM +0530, Abinash Singh wrote:
> The function serial8250_probe_acpi() in 8250_platform.c triggered a
> frame size warning:
> drivers/tty/serial/8250/8250_platform.c: In function ‘serial8250_probe_acpi’:
> drivers/tty/serial/8250/8250_platform.c:152:1: warning: the frame size of 1160 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> This patch reduces the stack usage by dynamically allocating the
> `uart` structure using kmalloc(), rather than placing it on
> the stack. This eliminates the overflow warning and improves kernel
> robustness.
...
> #include <linux/platform_device.h>
> -
Stray change.
> +#include <linux/cleanup.h>
Please, keep it ordered.
> #include <linux/serial_8250.h>
...
> struct device *dev = &pdev->dev;
> - struct uart_8250_port uart = { };
> + struct uart_8250_port *uart __free(kfree) = NULL;
> struct resource *regs;
> int ret, line;
>
> + uart = kmalloc(sizeof(*uart), GFP_KERNEL);
Just declare variable here, as the NULL assignment may lead to subtle issues.
> + if (!uart)
> + return -ENOMEM;
> + memset(uart, 0, sizeof(*uart));
We have kzalloc() for this.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists