[11/15] tty: Add bug-on in tty_test_and_set

Submitted by Cyrill Gorcunov on Sept. 7, 2018, 4:18 p.m.

Details

Message ID 20180907161836.25738-12-gorcunov@gmail.com
State Accepted
Series "tty: Add support for multiple devtps instances"
Headers show

Commit Message

Cyrill Gorcunov Sept. 7, 2018, 4:18 p.m.
To make sure we never overwrite memory by accident.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/tty.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index 0b96b961f38f..50b7de6812ec 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -522,6 +522,8 @@  static int tty_test_and_set(int bit, unsigned long *bitmap)
 {
 	int ret;
 
+	BUG_ON(bit >= TTY_BITMAP_BITS);
+
 	ret = test_bit(bit, bitmap);
 	if (!ret)
 		set_bit(bit, bitmap);