]> git.baikalelectronics.ru Git - kernel.git/commit
Input: turbografx - fix potential out of bound access
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 30 Jul 2015 18:01:13 +0000 (11:01 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 3 Aug 2015 21:11:45 +0000 (14:11 -0700)
commit0d8fb4851273ef3e0f43b3c0b082d7435694c2e2
tree0cfbf09be90866e7d1988227987b43dbbab53985
parent13b42d852bc433ec8a70a6aed306dcaf9a5ad7be
Input: turbografx - fix potential out of bound access

Patch 3dfdef1888a4: "[PATCH] drivers/input/joystick: convert to dynamic
input_dev allocation" from Sep 15, 2005, leads to the following static
checker warning:

        drivers/input/joystick/turbografx.c:235 tgfx_probe()
        error: buffer overflow 'tgfx_buttons' 5 <= 5

drivers/input/joystick/turbografx.c
   195          for (i = 0; i < n_devs; i++) {
   196                  if (n_buttons[i] < 1)
   197                          continue;
   198
   199                  if (n_buttons[i] > 6) {
                            ^^^^^^^^^^^^^^^^
Possibly off by one.  >= 6.

Let's change the upper value to ARRAY_SIZE(tgfx_buttons) to ensure we do
not reach past the end of the array.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/joystick/turbografx.c