usb: max-3421: Prevent corruption of freed memory
authorMark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Fri, 25 Jun 2021 03:14:56 +0000 (15:14 +1200)
committerPDO SCM Team <hudsoncm@motorola.com>
Mon, 6 Dec 2021 08:55:49 +0000 (03:55 -0500)
commit10628124a48b25417d0dffd084310be07d10e11e
treebee88d83b917b904ef0c37df9b29c9e2eb6f56ba
parent7db62d364b6709932073633cef5ea1e85806614b
usb: max-3421: Prevent corruption of freed memory

commit b5fdf5c6e6bee35837e160c00ac89327bdad031b upstream.

The MAX-3421 USB driver remembers the state of the USB toggles for a
device/endpoint. To save SPI writes, this was only done when a new
device/endpoint was being used. Unfortunately, if the old device was
removed, this would cause writes to freed memory.

To fix this, a simpler scheme is used. The toggles are read from
hardware when a URB is completed, and the toggles are always written to
hardware when any URB transaction is started. This will cause a few more
SPI transactions, but no causes kernel panics.

Mot-CRs-fixed: (CR)
CVE-Fixed: CVE-2021-38204
Bug: 196448784

Change-Id: Ie6d99df877c88d600a79d0bd32c0df75088c4fa9
Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20210625031456.8632-1-mark.tomlinson@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gajjala Chakradhar <gajjalac@motorola.com>
Reviewed-on: https://gerrit.mot.com/2123621
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
(cherry picked from commit c964c78643ef0ee22b7ec46bba981d8fd68d872f)
drivers/usb/host/max3421-hcd.c