]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
usb: udc: lpc32xx: fix bad bit shift operation
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 14 Oct 2019 19:18:30 +0000 (14:18 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 12 Nov 2019 17:46:47 +0000 (18:46 +0100)
commit2aeb20ba7fe19dfa273a61efdfe13ad8e1b8e951
tree403dab05b6cc26dca502153dd12cdecae1177f05
parent43eb3b3cfda326b17ca40e31af9a7fbc4f304b2f
usb: udc: lpc32xx: fix bad bit shift operation

BugLink: https://bugs.launchpad.net/bugs/1850456
commit b987b66ac3a2bc2f7b03a0ba48a07dc553100c07 upstream.

It seems that the right variable to use in this case is *i*, instead of
*n*, otherwise there is an undefined behavior when right shifiting by more
than 31 bits when multiplying n by 8; notice that *n* can take values
equal or greater than 4 (4, 8, 16, ...).

Also, notice that under the current conditions (bl = 3), we are skiping
the handling of bytes 3, 7, 31... So, fix this by updating this logic
and limit *bl* up to 4 instead of up to 3.

This fix is based on function udc_stuff_fifo().

Addresses-Coverity-ID: 1454834 ("Bad bit shift operation")
Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Link: https://lore.kernel.org/r/20191014191830.GA10721@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/usb/gadget/udc/lpc32xx_udc.c