[Devel] [PATCH RHEL7 COMMIT] vtty: possible ERR_PTR dereferencing in vtty_open_master
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jun 3 13:10:33 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.151.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.151.11
------>
commit 3b28361b1c11898a9224bb922d7ea262d1747171
Author: Vasily Averin <vvs at virtuozzo.com>
Date: Sun May 31 16:23:28 2020 +0300
vtty: possible ERR_PTR dereferencing in vtty_open_master
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>
Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
v2: do set proper "ret" values on error paths
---
drivers/tty/pty.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 698717e590503..17c5f51734762 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -1294,10 +1294,17 @@ int vtty_open_master(envid_t veid, int idx)
vtty_set_context(veid);
tty = vtty_lookup(vttym_driver, NULL, idx);
+ if (IS_ERR(tty)) {
+ ret = PTR_ERR(tty);
+ goto err_install;
+ }
+
if (!tty) {
tty = tty_init_dev(vttys_driver, idx);
- if (IS_ERR(tty))
+ if (IS_ERR(tty)) {
+ ret = PTR_ERR(tty);
goto err_install;
+ }
tty->count--;
tty_unlock(tty);
tty_set_lock_subclass(tty);
More information about the Devel
mailing list