Luis R. Rodriguez ac68b1b3b9 lib/test_kmod.c: fix limit check on number of test devices created
As reported by Dan the parentheses is in the wrong place, and since
unlikely() call returns either 0 or 1 it's never less than zero.  The
second issue is that signed integer overflows like "INT_MAX + 1" are
undefined behavior.

Since num_test_devs represents the number of devices, we want to stop
prior to hitting the max, and not rely on the wrap arround at all.  So
just cap at num_test_devs + 1, prior to assigning a new device.

Link: http://lkml.kernel.org/r/20180224030046.24238-1-mcgrof@kernel.org
Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-03-09 16:40:02 -08:00
..
2017-12-22 19:39:09 +11:00
2017-08-15 09:02:08 -07:00
2017-12-01 13:09:40 -08:00
2017-12-01 13:09:40 -08:00
2015-11-23 09:44:58 +01:00
2017-12-01 13:09:40 -08:00
2018-02-06 18:32:44 -08:00
2018-01-01 12:40:27 -07:00
2018-02-06 18:32:44 -08:00
2017-10-07 10:45:14 -06:00
2017-02-24 17:46:57 -08:00
2018-02-26 14:39:30 -05:00
2017-11-17 16:10:01 -08:00
2018-01-31 11:32:27 -08:00
2018-02-06 18:32:47 -08:00
2018-02-01 10:00:28 -08:00
2017-12-01 13:09:40 -08:00
2017-12-01 13:09:40 -08:00
2016-12-06 10:17:03 +02:00
2018-02-21 15:35:43 -08:00
2018-01-15 09:35:50 +01:00
2018-02-28 17:49:18 +01:00
2017-12-01 13:09:40 -08:00
2017-08-15 09:02:07 -07:00