linux/drivers/usb/chipidea
Fabio Estevam 8253a34bfa usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle
When passing 'phys' in the devicetree to describe the USB PHY phandle
(which is the recommended way according to
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt) the
following NULL pointer dereference is observed on i.MX7 and i.MX8MM:

[    1.489344] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
[    1.498170] Mem abort info:
[    1.500966]   ESR = 0x96000044
[    1.504030]   EC = 0x25: DABT (current EL), IL = 32 bits
[    1.509356]   SET = 0, FnV = 0
[    1.512416]   EA = 0, S1PTW = 0
[    1.515569]   FSC = 0x04: level 0 translation fault
[    1.520458] Data abort info:
[    1.523349]   ISV = 0, ISS = 0x00000044
[    1.527196]   CM = 0, WnR = 1
[    1.530176] [0000000000000098] user address but active_mm is swapper
[    1.536544] Internal error: Oops: 96000044 [#1] PREEMPT SMP
[    1.542125] Modules linked in:
[    1.545190] CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.14.0-dirty #3
[    1.551901] Hardware name: Kontron i.MX8MM N801X S (DT)
[    1.557133] Workqueue: events_unbound deferred_probe_work_func
[    1.562984] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
[    1.568998] pc : imx7d_charger_detection+0x3f0/0x510
[    1.573973] lr : imx7d_charger_detection+0x22c/0x510

This happens because the charger functions check for the phy presence
inside the imx_usbmisc_data structure (data->usb_phy), but the chipidea
core populates the usb_phy passed via 'phys' inside 'struct ci_hdrc'
(ci->usb_phy) instead.

This causes the NULL pointer dereference inside imx7d_charger_detection().

Fix it by also searching for 'phys' in case 'fsl,usbphy' is not found.

Tested on a imx7s-warp board.

Fixes: 746f316b75 ("usb: chipidea: introduce imx7d USB charger detection")
Cc: stable@vger.kernel.org
Reported-by: Heiko Thiery <heiko.thiery@gmail.com>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Acked-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Link: https://lore.kernel.org/r/20210921113754.767631-1-festevam@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-05 13:47:26 +02:00
..
bits.h
ci_hdrc_imx.c usb: chipidea: ci_hdrc_imx: Also search for 'phys' phandle 2021-10-05 13:47:26 +02:00
ci_hdrc_imx.h usb: chipidea: imx: add two samsung picophy parameters tuning implementation 2020-08-23 11:40:08 +08:00
ci_hdrc_msm.c usb: chipidea: msm: Ensure proper controller reset using role switch API 2020-05-07 08:46:35 +02:00
ci_hdrc_pci.c usb: chipidea: ci_hdrc_pci: Fix improper use of kerneldoc format 2020-07-09 17:19:56 +02:00
ci_hdrc_tegra.c usb: chipidea: tegra: Silence deferred probe error 2021-03-23 12:50:32 +01:00
ci_hdrc_usb2.c usb: chipidea: usb2: remove unneeded semicolon 2020-04-29 09:47:19 +08:00
ci.h USB: chipidea: remove dentry storage for debugfs file 2021-05-27 09:34:34 +02:00
core.c usb: chipidea: core: Fix incorrectly documented function 'ci_usb_phy_exit()' 2021-05-27 09:43:44 +02:00
debug.c USB: chipidea: remove dentry storage for debugfs file 2021-05-27 09:34:34 +02:00
host.c usb: chipidea: host: fix port index underflow and UBSAN complains 2021-08-21 13:15:25 +08:00
host.h
Kconfig usb: chipidea: tegra: Support host mode 2021-01-13 11:26:34 +01:00
Makefile usb: chipidea: add tracepoint support for udc 2020-12-10 08:45:26 +08:00
otg_fsm.c
otg_fsm.h
otg.c usb: chipidea: otg: Fix formatting and missing documentation issues 2021-05-27 09:43:44 +02:00
otg.h
trace.c usb: chipidea: add tracepoint support for udc 2020-12-10 08:45:26 +08:00
trace.h usb: chipidea: trace: fix the endian issue 2020-12-10 08:45:26 +08:00
udc.c Merge 5.13-rc4 into usb-next 2021-05-31 09:50:26 +02:00
udc.h usb: chipidea: udc: add software sg list support 2020-05-06 09:42:35 +08:00
ulpi.c
usbmisc_imx.c usb: chipidea: imx: Fix Battery Charger 1.2 CDP detection 2021-06-16 09:04:22 +08:00