* [PATCH] serial: sh-sci: Unregister UART on sysfs setup failure
@ 2026-09-11 3:15 Myeonghun Pak
2026-09-11 3:20 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-11 3:15 UTC (permalink / raw)
To: gregkh, jirislaby; +Cc: linux-serial, linux-kernel, linux-renesas-soc, Ijae Kim
sci_probe_single() registers the UART port before sci_probe() creates
the RX FIFO tuning attributes. If either device_create_file() call
fails, probe returns an error without removing the port from the serial
core. Device-managed resources are then released while the port remains
registered.
Unregister the UART port before returning either sysfs creation error.
If the second attribute fails, remove the first attribute before
unregistering the port. Keep the existing probe failure policy and leave
the successful initialization path unchanged.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 5d23188a473d ("serial: sh-sci: make RX FIFO parameters tunable via sysfs")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/tty/serial/sh-sci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 92193eb26abf5e2de6386389708e635e42d33c8b..50ae9aae6b6146493a5c080a0f0cbb7351a89b3a 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3937,12 +3937,12 @@ static int sci_probe(struct platform_device *dev)
if (sp->port.fifosize > 1) {
ret = device_create_file(&dev->dev, &dev_attr_rx_fifo_trigger);
if (ret)
- return ret;
+ goto err_remove_port;
ret = device_create_file(&dev->dev, &dev_attr_rx_fifo_timeout);
if (ret) {
device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger);
- return ret;
+ goto err_remove_port;
}
}
@@ -3952,6 +3952,10 @@ static int sci_probe(struct platform_device *dev)
sci_ports_in_use |= BIT(dev_id);
return 0;
+
+err_remove_port:
+ uart_remove_one_port(&sci_uart_driver, &sp->port);
+ return ret;
}
static int sci_suspend(struct device *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: sh-sci: Unregister UART on sysfs setup failure
2026-09-11 3:15 [PATCH] serial: sh-sci: Unregister UART on sysfs setup failure Myeonghun Pak
@ 2026-09-11 3:20 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-09-11 3:20 UTC (permalink / raw)
To: Myeonghun Pak; +Cc: linux-serial, wsa+renesas
> sci_probe_single() registers the UART port before sci_probe() creates
> the RX FIFO tuning attributes. If either device_create_file() call
> fails, probe returns an error without removing the port from the serial
> core. Device-managed resources are then released while the port remains
> registered.
>
> Unregister the UART port before returning either sysfs creation error.
> If the second attribute fails, remove the first attribute before
> unregistering the port. Keep the existing probe failure policy and leave
> the successful initialization path unchanged.
>
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
>
> Fixes: 5d23188a473d ("serial: sh-sci: make RX FIFO parameters tunable via sysfs")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911031500.5745-1-mhun512@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-11 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 3:15 [PATCH] serial: sh-sci: Unregister UART on sysfs setup failure Myeonghun Pak
2026-09-11 3:20 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox