[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221229161948.594102-1-brgl@bgdev.pl>
Date: Thu, 29 Dec 2022 17:19:46 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Gross <agross@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konrad.dybcio@...ainline.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Vinod Koul <vkoul@...nel.org>, Alex Elder <elder@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-serial@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: [RESEND PATCH 0/2] tty: serial: add and use a managed variant of uart_add_one_port()
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Resending rebased on top of v6.2-rc1
--
This series adds a managed variant of uart_add_one_port() and uses it in the
qcom-geni-serial driver.
I've been asked by Greg to send it separately and he didn't seem to be
impressed by the proposition of adding devres interfaces to the tty layer
in general. I can only assume it has something to do with the ongoing
discussion about the supposed danger of using devres interfaces in conjunction
with exporting character devices to user-space.
The bug in question can be triggered by opening a device file, unbinding the
driver that exported it and then calling any of the system calls on the
associated file descriptor.
After some testing I noticed that many subsystems are indeed either crashing
or deadlocking in the above situation. I've sent patches that attempt to fix
the GPIO and I2C subsystems[1][2]. Neither of these issues have anything to
do with devres and all to do with the fact that certain resources are freed
on driver unbind and others need to live for as long as the character device
exists. More details on that in the cover letters and commit messages in the
links.
I'd like to point out that the serial code is immune to this issue as before
every operation, the serial core takes the port lock and checks the uart
state. If the device no longer exists (when the uart port is removed, the
pointer to uart_port inside uart_state is to NULL), it gracefully returns
-ENODEV to user-space.
Please consider applying the patches in the series as devres is the easiest
way to lessen the burden on driver developers when dealing with complex error
paths and resource leaks. The general rule for devres is: if it can be freed
in .remove() then it can be managed by devres, which is the case for this new
helper.
Bart
[1] https://lkml.org/lkml/2022/12/8/826
[2] https://lkml.org/lkml/2022/12/5/414
Bartosz Golaszewski (2):
tty: serial: provide devm_uart_add_one_port()
tty: serial: qcom-geni-serial: use devres for uart port management
.../driver-api/driver-model/devres.rst | 3 ++
drivers/tty/serial/qcom_geni_serial.c | 8 +---
drivers/tty/serial/serial_core.c | 48 +++++++++++++++++++
include/linux/serial_core.h | 6 +++
4 files changed, 58 insertions(+), 7 deletions(-)
--
2.37.2
Powered by blists - more mailing lists