Skip to content

Commit 4993508

Browse files
Fabio EstevamFelipe Balbi
Fabio Estevam
authored and
Felipe Balbi
committed
usb: phy: mxs: Fix NULL pointer dereference on i.MX23/28
Commit e936509 ("usb: phy: mxs: add usb charger type detection") causes the following kernel hang on i.MX28: [ 2.207973] usbcore: registered new interface driver usb-storage [ 2.235659] Unable to handle kernel NULL pointer dereference at virtual address 00000188 [ 2.244195] pgd = (ptrval) [ 2.246994] [00000188] *pgd=00000000 [ 2.250676] Internal error: Oops: 5 [anholt#1] ARM [ 2.254979] Modules linked in: [ 2.258089] CPU: 0 PID: 1 Comm: swapper Not tainted 4.15.0-rc8-next-20180117-00002-g75d5f21 anholt#7 [ 2.266724] Hardware name: Freescale MXS (Device Tree) [ 2.271921] PC is at regmap_read+0x0/0x5c [ 2.275977] LR is at mxs_phy_charger_detect+0x34/0x1dc mxs_phy_charger_detect() makes accesses to the anatop registers via regmap, however i.MX23/28 do not have such registers, which causes a NULL pointer dereference. Fix the issue by doing a NULL check on the 'regmap' pointer. Fixes: e936509 ("usb: phy: mxs: add usb charger type detection") Cc: <[email protected]> # v4.15 Reviewed-by: Li Jun <[email protected]> Acked-by: Peter Chen <[email protected]> Signed-off-by: Fabio Estevam <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent c4a5153 commit 4993508

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/usb/phy/phy-mxs-usb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ static enum usb_charger_type mxs_phy_charger_detect(struct usb_phy *phy)
602602
void __iomem *base = phy->io_priv;
603603
enum usb_charger_type chgr_type = UNKNOWN_TYPE;
604604

605+
if (!regmap)
606+
return UNKNOWN_TYPE;
607+
605608
if (mxs_charger_data_contact_detect(mxs_phy))
606609
return chgr_type;
607610

0 commit comments

Comments
 (0)