[RHEL7,COMMIT] vtty: fixed error path in vtty_map_alloc

Submitted by Konstantin Khorenko on June 1, 2020, 3:31 p.m.

Details

Message ID 202006011531.051FVKA5025270@finist-ce7.sw.ru
State New
Series "vtty: fixed error path in vtty_map_alloc"
Headers show

Commit Message

Konstantin Khorenko June 1, 2020, 3:31 p.m.
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@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@virtuozzo.com>
---
 drivers/tty/pty.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

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