Skip to content

Commit

Permalink
phy: gmii2rgmii: Add check for external phy driver
Browse files Browse the repository at this point in the history
Add a check for external phy driver to be probed before dereferencing
phy driver pointer. This fixes the following crash:

[    2.439334] libphy: MACB_mii_bus: probed
[    2.444797] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    2.452689] Mem abort info:
[    2.455453]   Exception class = DABT (current EL), IL = 32 bits
[    2.461334]   SET = 0, FnV = 0
[    2.464361]   EA = 0, S1PTW = 0
[    2.467474] Data abort info:
[    2.470325]   ISV = 0, ISS = 0x00000005
[    2.474135]   CM = 0, WnR = 0
[    2.477077] [0000000000000000] user address but active_mm is swapper
[    2.483392] Internal error: Oops: 96000005 1 SMP
[    2.488232] Modules linked in:
[    2.491261] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.14.0-xilinx-v2018.2 #1
[    2.498438] Hardware name: ZynqMP ZC1275 RevB (DT)
[    2.503196] task: ffffffc06d846d00 task.stack: ffffff8008038000
[    2.509085] PC is at __memcpy+0x100/0x180
[    2.513061] LR is at xgmiitorgmii_probe+0x7c/0xf0

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
  • Loading branch information
harini-katakam authored and michalsimek committed Jun 7, 2018
1 parent 7a6053b commit 3767e23
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/phy/xilinx_gmii2rgmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev)
return -EPROBE_DEFER;
}

if (!priv->phy_dev->drv) {
dev_err(dev, "External PHY driver not probed\n");
return -EPROBE_DEFER;
}

priv->addr = mdiodev->addr;
priv->phy_drv = priv->phy_dev->drv;
memcpy(&priv->conv_phy_drv, priv->phy_dev->drv,
Expand Down

0 comments on commit 3767e23

Please sign in to comment.