From: Vasily Averin <[email protected]>

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

Signed-off-by: Vasily Averin <[email protected]>
Acked-by: Konstantin Khorenko <[email protected]>

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);
-- 
2.15.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to