[Devel] [PATCH RH7] vtty: fixed error path in vtty_map_alloc
    Vasily Averin 
    vvs at virtuozzo.com
       
    Sun May 31 16:23:21 MSK 2020
    
    
  
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 9e00e9b..698717e 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);
-- 
1.8.3.1
    
    
More information about the Devel
mailing list