Skip to content

Commit 7293adc

Browse files
Uwe Kleine-Königguilemop-ext
authored andcommitted
serial: stm32: Ignore return value of uart_remove_one_port() in .remove()
[ Upstream commit 6bd6cd2 ] Returning early from stm32_usart_serial_remove() results in a resource leak as several cleanup functions are not called. The driver core ignores the return value and there is no possibility to clean up later. uart_remove_one_port() only returns non-zero if there is some inconsistency (i.e. stm32_usart_driver.state[port->line].uart_port == NULL). This should never happen, and even if it does it's a bad idea to exit early in the remove callback without cleaning up. This prepares changing the prototype of struct platform_driver::remove to return void. See commit 5c5a768 ("platform: Provide a remove callback that returns no value") for further details about this quest. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230512173810.131447-2-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Change-Id: I5f9e87e6ffacfe32332497f034191bed7eacaa7e Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/320775 ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> Reviewed-by: Amelie DELAUNAY <amelie.delaunay@foss.st.com> ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> Domain-Review: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
1 parent 17546ea commit 7293adc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/tty/serial/stm32-usart.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,13 +2044,10 @@ static int stm32_usart_serial_remove(struct platform_device *pdev)
20442044
struct uart_port *port = platform_get_drvdata(pdev);
20452045
struct stm32_port *stm32_port = to_stm32_port(port);
20462046
const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
2047-
int err;
20482047
u32 cr3;
20492048

20502049
pm_runtime_get_sync(&pdev->dev);
2051-
err = uart_remove_one_port(&stm32_usart_driver, port);
2052-
if (err)
2053-
return(err);
2050+
uart_remove_one_port(&stm32_usart_driver, port);
20542051

20552052
pm_runtime_disable(&pdev->dev);
20562053
pm_runtime_set_suspended(&pdev->dev);

0 commit comments

Comments
 (0)