[Devel] [PATCH RHEL7 COMMIT] vtty: fixed error path in vtty_map_alloc

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 1 18:31:20 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.9
------>
commit 45a6784e0d9e25ea0a01c415f099b839e2c4fdfc
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Sun May 31 16:23:21 2020 +0300

    vtty: fixed error path in vtty_map_alloc
    
    found by smatch:
    drivers/tty/pty.c:935 vtty_map_alloc() warn:
     unsigned 'veid' is never less than zero.
    
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 drivers/tty/pty.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 9e00e9bbd7275..698717e590503 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -930,11 +930,13 @@ static vtty_map_t *vtty_map_alloc(envid_t veid)
 
 	lockdep_assert_held(&tty_mutex);
 	if (map) {
+		int id;
+
 		map->veid = veid;
-		veid = idr_alloc(&vtty_idr, map, veid, veid + 1, GFP_KERNEL);
-		if (veid < 0) {
+		id = idr_alloc(&vtty_idr, map, veid, veid + 1, GFP_KERNEL);
+		if (id < 0) {
 			kfree(map);
-			return ERR_PTR(veid);
+			return ERR_PTR(id);
 		}
 	} else
 		map = ERR_PTR(-ENOMEM);


More information about the Devel mailing list