linux_dsm_epyc7002/drivers/usb/chipidea
Jisheng Zhang aa1f058d7d usb: chipidea: udc: fix NULL pointer dereference if udc_start failed
Fix below NULL pointer dereference. we set ci->roles[CI_ROLE_GADGET]
too early in ci_hdrc_gadget_init(), if udc_start() fails due to some
reason, the ci->roles[CI_ROLE_GADGET] check in  ci_hdrc_gadget_destroy
can't protect us.

We fix this issue by only setting ci->roles[CI_ROLE_GADGET] if
udc_start() succeed.

[    1.398550] Unable to handle kernel NULL pointer dereference at
virtual address 00000000
...
[    1.448600] PC is at dma_pool_free+0xb8/0xf0
[    1.453012] LR is at dma_pool_free+0x28/0xf0
[    2.113369] [<ffffff80081817d8>] dma_pool_free+0xb8/0xf0
[    2.118857] [<ffffff800841209c>] destroy_eps+0x4c/0x68
[    2.124165] [<ffffff8008413770>] ci_hdrc_gadget_destroy+0x28/0x50
[    2.130461] [<ffffff800840fa30>] ci_hdrc_probe+0x588/0x7e8
[    2.136129] [<ffffff8008380fb8>] platform_drv_probe+0x50/0xb8
[    2.142066] [<ffffff800837f494>] driver_probe_device+0x1fc/0x2a8
[    2.148270] [<ffffff800837f68c>] __device_attach_driver+0x9c/0xf8
[    2.154563] [<ffffff800837d570>] bus_for_each_drv+0x58/0x98
[    2.160317] [<ffffff800837f174>] __device_attach+0xc4/0x138
[    2.166072] [<ffffff800837f738>] device_initial_probe+0x10/0x18
[    2.172185] [<ffffff800837e58c>] bus_probe_device+0x94/0xa0
[    2.177940] [<ffffff800837c560>] device_add+0x3f0/0x560
[    2.183337] [<ffffff8008380d20>] platform_device_add+0x180/0x240
[    2.189541] [<ffffff800840f0e8>] ci_hdrc_add_device+0x440/0x4f8
[    2.195654] [<ffffff8008414194>] ci_hdrc_usb2_probe+0x13c/0x2d8
[    2.201769] [<ffffff8008380fb8>] platform_drv_probe+0x50/0xb8
[    2.207705] [<ffffff800837f494>] driver_probe_device+0x1fc/0x2a8
[    2.213910] [<ffffff800837f5ec>] __driver_attach+0xac/0xb0
[    2.219575] [<ffffff800837d4b0>] bus_for_each_dev+0x60/0xa0
[    2.225329] [<ffffff800837ec80>] driver_attach+0x20/0x28
[    2.230816] [<ffffff800837e880>] bus_add_driver+0x1d0/0x238
[    2.236571] [<ffffff800837fdb0>] driver_register+0x60/0xf8
[    2.242237] [<ffffff8008380ef4>] __platform_driver_register+0x44/0x50
[    2.248891] [<ffffff80086fd440>] ci_hdrc_usb2_driver_init+0x18/0x20
[    2.255365] [<ffffff8008082950>] do_one_initcall+0x38/0x128
[    2.261121] [<ffffff80086e0d00>] kernel_init_freeable+0x1ac/0x250
[    2.267414] [<ffffff800852f0b8>] kernel_init+0x10/0x100
[    2.272810] [<ffffff8008082680>] ret_from_fork+0x10/0x50

Cc: stable <stable@vger.kernel.org>
Fixes: 3f124d233e ("usb: chipidea: add role init and destroy APIs")
Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
2017-05-18 09:07:14 +08:00
..
bits.h usb: chipidea: add tx/rx burst size configuration interface 2015-08-14 10:03:58 +08:00
ci_hdrc_imx.c usb: chipidea: imx: configure imx for ULPI phy 2016-11-14 10:03:40 +08:00
ci_hdrc_imx.h usb: chipidea: imx: configure imx for ULPI phy 2016-11-14 10:03:40 +08:00
ci_hdrc_msm.c usb: chipidea: msm: Fix return value check in ci_hdrc_msm_probe() 2017-02-03 16:48:47 +08:00
ci_hdrc_pci.c usb: chipidea: fix return value check in ci_hdrc_pci_probe() 2016-02-19 14:13:44 +08:00
ci_hdrc_usb2.c usb: chipidea: usb2: delete the redundant setting default DMA mask code 2017-01-23 17:02:39 +08:00
ci_hdrc_zevio.c Chipidea: TI-NSPIRE USB OTG hardware does not support high speed and must connect at full speed 2015-03-18 16:19:11 +01:00
ci.h usb: chipidea: udc: update gadget state after bus resume 2017-03-15 11:30:43 +08:00
core.c Two changes for this v4.12-rc1: 2017-04-18 16:52:20 +02:00
debug.c chipidea: error on overflow for port_test_write 2016-02-20 20:15:57 -08:00
host.c usb: chipidea: use bus->sysdev for DMA configuration 2017-03-23 08:20:21 +01:00
host.h usb: chipidea: ehci_init_driver is intended to call one time 2015-07-22 08:03:41 +08:00
Kconfig usb: add CONFIG_USB_PCI for system have both PCI HW and non-PCI based USB HW 2017-03-17 13:16:56 +09:00
Makefile usb: chipidea: Add support for ULPI PHY bus 2017-01-20 11:25:14 +08:00
otg_fsm.c ktime: Get rid of the union 2016-12-25 17:21:22 +01:00
otg_fsm.h usb: chipidea: otg: add A idle to B disconnect timer 2016-03-04 15:14:38 +02:00
otg.c usb: chipidea: vbus event may exist before starting gadget 2017-01-20 15:24:59 +08:00
otg.h usb: chipidea: using one inline function to cover queue work operations 2014-05-23 11:35:02 +09:00
udc.c usb: chipidea: udc: fix NULL pointer dereference if udc_start failed 2017-05-18 09:07:14 +08:00
udc.h usb: chipidea: Properly mark little endian descriptors 2016-11-14 10:03:40 +08:00
ulpi.c usb: chipidea: Add support for ULPI PHY bus 2017-01-20 11:25:14 +08:00
usbmisc_imx.c usb: chipidea: imx: Do not access CLKONOFF on i.MX51 2017-05-18 09:06:25 +08:00