linux_dsm_epyc7002/drivers/usb/host
Zhangjiantao (Kirin, nanjing) b242ae99fa xhci: solve a double free problem while doing s4
commit b31d9d6d7abbf6483b871b6370bc31c930d53f54 upstream.

when system is doing s4, the process of xhci_resume may be as below:
1、xhci_mem_cleanup
2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough).
xhci_mem_cleanup will be executed twice when system is out of memory.
xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL.
It will be freed twice when xhci_mem_cleanup is called the second time.

We got following bug when system resumes from s4:

kernel BUG at mm/slub.c:309!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
CPU: 0 PID: 5929 Tainted: G S   W   5.4.96-arm64-desktop #1
pc : __slab_free+0x5c/0x424
lr : kfree+0x30c/0x32c

Call trace:
 __slab_free+0x5c/0x424
 kfree+0x30c/0x32c
 xhci_mem_cleanup+0x394/0x3cc
 xhci_mem_init+0x9ac/0x1070
 xhci_init+0x8c/0x1d0
 xhci_resume+0x1cc/0x5fc
 xhci_plat_resume+0x64/0x70
 platform_pm_thaw+0x28/0x60
 dpm_run_callback+0x54/0x24c
 device_resume+0xd0/0x200
 async_resume+0x24/0x60
 async_run_entry_fn+0x44/0x110
 process_one_work+0x1f0/0x490
 worker_thread+0x5c/0x450
 kthread+0x158/0x160
 ret_from_fork+0x10/0x24

Original patch that caused this issue was backported to 4.4 stable,
so this should be backported to 4.4 stabe as well.

Fixes: cf0ee7c60c ("xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2")
Cc: stable@vger.kernel.org # v4.4+
Signed-off-by: Jiantao Zhang <water.zhangjiantao@huawei.com>
Signed-off-by: Tao Xue <xuetao09@huawei.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20210617150354.1512157-5-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-14 16:55:38 +02:00
..
bcma-hcd.c
ehci-atmel.c
ehci-brcm.c
ehci-dbg.c
ehci-exynos.c
ehci-fsl.c
ehci-fsl.h
ehci-grlib.c
ehci-hcd.c
ehci-hub.c
ehci-mem.c
ehci-mv.c
ehci-mxc.c
ehci-npcm7xx.c
ehci-omap.c
ehci-orion.c
ehci-pci.c
ehci-platform.c
ehci-pmcmsp.c
ehci-ppc-of.c
ehci-ps3.c
ehci-q.c
ehci-sched.c
ehci-sh.c
ehci-spear.c
ehci-st.c
ehci-sysfs.c
ehci-tegra.c
ehci-timer.c
ehci-xilinx-of.c
ehci.h
fhci-dbg.c
fhci-hcd.c
fhci-hub.c
fhci-mem.c
fhci-q.c
fhci-sched.c
fhci-tds.c
fhci.h
fotg210-hcd.c usb: fotg210-hcd: Fix an error message 2021-05-19 10:13:13 +02:00
fotg210.h
fsl-mph-dr-of.c
imx21-dbg.c
imx21-hcd.c
imx21-hcd.h
isp116x-hcd.c
isp116x.h
isp1362-hcd.c
isp1362.h
Kconfig
Makefile
max3421-hcd.c
ohci-at91.c
ohci-da8xx.c
ohci-dbg.c
ohci-exynos.c
ohci-hcd.c
ohci-hub.c
ohci-mem.c
ohci-nxp.c
ohci-omap.c
ohci-pci.c
ohci-platform.c
ohci-ppc-of.c
ohci-ps3.c
ohci-pxa27x.c
ohci-q.c
ohci-s3c2410.c
ohci-sa1111.c
ohci-sm501.c
ohci-spear.c
ohci-st.c
ohci-tmio.c
ohci.h
oxu210hp-hcd.c
pci-quirks.c
pci-quirks.h
r8a66597-hcd.c
r8a66597.h
sl811_cs.c
sl811-hcd.c usb: sl811-hcd: improve misleading indentation 2021-05-22 11:40:51 +02:00
sl811.h
ssb-hcd.c
u132-hcd.c
uhci-debug.c
uhci-grlib.c
uhci-hcd.c
uhci-hcd.h
uhci-hub.c
uhci-pci.c
uhci-platform.c
uhci-q.c
xhci-dbg.c
xhci-dbgcap.c
xhci-dbgcap.h
xhci-dbgtty.c
xhci-debugfs.c
xhci-debugfs.h
xhci-ext-caps.c
xhci-ext-caps.h usb: xhci: Increase timeout for HC halt 2021-05-19 10:13:15 +02:00
xhci-histb.c
xhci-hub.c
xhci-mem.c xhci: solve a double free problem while doing s4 2021-07-14 16:55:38 +02:00
xhci-mtk-sch.c usb: xhci-mtk: improve bandwidth scheduling with TT 2021-05-14 09:49:57 +02:00
xhci-mtk.c usb: xhci-mtk: support quirk to disable usb2 lpm 2021-05-11 14:47:19 +02:00
xhci-mtk.h usb: xhci-mtk: improve bandwidth scheduling with TT 2021-05-14 09:49:57 +02:00
xhci-mvebu.c usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 2021-02-10 09:29:10 +01:00
xhci-mvebu.h usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 2021-02-10 09:29:10 +01:00
xhci-pci-renesas.c usb: renesas-xhci: Fix handling of unknown ROM state 2021-07-14 16:55:37 +02:00
xhci-pci.c xhci: Add reset resume quirk for AMD xhci controller. 2021-05-19 10:13:16 +02:00
xhci-pci.h
xhci-plat.c usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 2021-02-10 09:29:10 +01:00
xhci-plat.h usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 2021-02-10 09:29:10 +01:00
xhci-rcar.c
xhci-rcar.h
xhci-ring.c usb: xhci: do not perform Soft Retry for some xHCI hosts 2021-03-17 17:06:30 +01:00
xhci-tegra.c xhci: tegra: Delay for disabling LFPS detector 2021-01-27 11:55:18 +01:00
xhci-trace.c
xhci-trace.h
xhci.c xhci: Do not use GFP_KERNEL in (potentially) atomic context 2021-05-19 10:13:15 +02:00
xhci.h usb: xhci: do not perform Soft Retry for some xHCI hosts 2021-03-17 17:06:30 +01:00