[Devel] [PATCH RH7] vtty: possible ERR_PTR dereferencing in vtty_open_master

Vasily Averin vvs at virtuozzo.com
Sun May 31 16:23:28 MSK 2020


found by swatch:
drivers/tty/pty.c:1306 vtty_open_master() error:
 'tty' dereferencing possible ERR_PTR()

Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 drivers/tty/pty.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 698717e..be25302 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -1294,6 +1294,9 @@ int vtty_open_master(envid_t veid, int idx)
 	vtty_set_context(veid);
 
 	tty = vtty_lookup(vttym_driver, NULL, idx);
+	if (IS_ERR(tty))
+		goto err_install;
+
 	if (!tty) {
 		tty = tty_init_dev(vttys_driver, idx);
 		if (IS_ERR(tty))
-- 
1.8.3.1



More information about the Devel mailing list