mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
usb: idmouse: fix an uninit-value in idmouse_open
In idmouse_create_image, if any ftip_command fails, it will go to the reset label. However, this leads to the data in bulk_in_buffer[HEADER..IMGSIZE] uninitialized. And the check for valid image incurs an uninitialized dereference. Fix this by moving the check before reset label since this check only be valid if the data after bulk_in_buffer[HEADER] has concrete data. Note that this is found by KMSAN, so only kernel compilation is tested. Reported-by: syzbot+79832d33eb89fb3cd092@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> Link: https://lore.kernel.org/r/20220922134847.1101921-1-dzm91@hust.edu.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
411c4597df
commit
bce2b05399
1 changed files with 4 additions and 4 deletions
|
@ -177,10 +177,6 @@ static int idmouse_create_image(struct usb_idmouse *dev)
|
||||||
bytes_read += bulk_read;
|
bytes_read += bulk_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the device */
|
|
||||||
reset:
|
|
||||||
ftip_command(dev, FTIP_RELEASE, 0, 0);
|
|
||||||
|
|
||||||
/* check for valid image */
|
/* check for valid image */
|
||||||
/* right border should be black (0x00) */
|
/* right border should be black (0x00) */
|
||||||
for (bytes_read = sizeof(HEADER)-1 + WIDTH-1; bytes_read < IMGSIZE; bytes_read += WIDTH)
|
for (bytes_read = sizeof(HEADER)-1 + WIDTH-1; bytes_read < IMGSIZE; bytes_read += WIDTH)
|
||||||
|
@ -192,6 +188,10 @@ static int idmouse_create_image(struct usb_idmouse *dev)
|
||||||
if (dev->bulk_in_buffer[bytes_read] != 0xFF)
|
if (dev->bulk_in_buffer[bytes_read] != 0xFF)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
|
/* reset the device */
|
||||||
|
reset:
|
||||||
|
ftip_command(dev, FTIP_RELEASE, 0, 0);
|
||||||
|
|
||||||
/* should be IMGSIZE == 65040 */
|
/* should be IMGSIZE == 65040 */
|
||||||
dev_dbg(&dev->interface->dev, "read %d bytes fingerprint data\n",
|
dev_dbg(&dev->interface->dev, "read %d bytes fingerprint data\n",
|
||||||
bytes_read);
|
bytes_read);
|
||||||
|
|
Loading…
Reference in a new issue