All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty_port: Restore tty port default ops on unregistering
@ 2020-01-29  8:07 Loic Poulain
  2020-02-04  9:47 ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: Loic Poulain @ 2020-01-29  8:07 UTC (permalink / raw)
  To: gregkh, jslaby; +Cc: linux-kernel, Loic Poulain

When a port is unregistered from serdev, its serdev specific client_ops
pointer is nullified, which can lead to future null pointer dereference.
Fix that by restoring default client_ops when port is unregistered from
serdev.

port registering/unregistering can happen several times, at least it
happens when statically registered 8250 ISA port are replaced at boot
time by e.g. device-tree defined 8250 ports.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/tty/tty_port.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index 044c3cb..bf893da 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -203,8 +203,10 @@ void tty_port_unregister_device(struct tty_port *port,
 	int ret;
 
 	ret = serdev_tty_port_unregister(port);
-	if (ret == 0)
+	if (ret == 0) {
+		port->client_ops = &default_client_ops;
 		return;
+	}
 
 	tty_unregister_device(driver, index);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-10 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-29  8:07 [PATCH] tty_port: Restore tty port default ops on unregistering Loic Poulain
2020-02-04  9:47 ` Johan Hovold
     [not found]   ` <CAMZdPi8R_bj4+HFjCmiRTJ2KgToMMuX0fbopGBOsMPMhJ4xsXQ@mail.gmail.com>
2020-02-10 14:54     ` Johan Hovold
2020-02-10 14:57       ` [PATCH] serdev: ttyport: restore client ops on deregistration Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.