Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: misc: cypress_cy7c63: check for short transfer

As we process the second byte of a control transfer, transfers
of less than 2 bytes must be discarded.

This bug is as old as the driver.

SIgned-off-by: Oliver Neukum <oneukum@suse.com>
CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240912125449.1030536-1-oneukum@suse.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Oliver Neukum and committed by
Greg Kroah-Hartman
49cd2f4d 8265d06b

+4
+4
drivers/usb/misc/cypress_cy7c63.c
··· 88 88 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, 89 89 address, data, iobuf, CYPRESS_MAX_REQSIZE, 90 90 USB_CTRL_GET_TIMEOUT); 91 + /* we must not process garbage */ 92 + if (retval < 2) 93 + goto err_buf; 91 94 92 95 /* store returned data (more READs to be added) */ 93 96 switch (request) { ··· 110 107 break; 111 108 } 112 109 110 + err_buf: 113 111 kfree(iobuf); 114 112 error: 115 113 return retval;