[RH7] vtty: fixed error path in vtty_map_alloc

Submitted by Vasily Averin on May 31, 2020, 1:23 p.m.

Details

Message ID cbe3b4df-91ab-0da2-d2d5-f36c9cd8c7a3@virtuozzo.com
State New
Series "vtty: fixed error path in vtty_map_alloc"
Headers show

Commit Message

Vasily Averin May 31, 2020, 1:23 p.m.
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 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);