Skip to content

Commit b793f08

Browse files
chunkeeydavem330
authored andcommitted
net: ibm: emac: fix regression caused by emac_dt_phy_probe()
Julian Margetson reported a panic on his SAM460EX with Kernel 4.11-rc1: | Unable to handle kernel paging request for data at address 0x00000014 | Oops: Kernel access of bad area, sig: 11 [#1] | PREEMPT | Canyonlands | Modules linked in: | CPU: 0 PID: 1 Comm: swapper Not tainted [...] | task: ea838000 task.stack: ea836000 | NIP: c0599f5c LR: c0599dd8 CTR: 00000000 | REGS: ea837c80 TRAP: 0300 Not tainted [...] | MSR: 00029000 <CE,EE,ME> | CR: 24371242 XER: 20000000 | DEAR: 00000014 ESR: 00000000 | GPR00: c0599ce8 ea837d30 ea838000 c0e52dcc c0d56ffb [...] | NIP [c0599f5c] emac_probe+0xfb4/0x1304 | LR [c0599dd8] emac_probe+0xe30/0x1304 | Call Trace: | [ea837d30] [c0599ce8] emac_probe+0xd40/0x1304 (unreliable) | [ea837d80] [c0533504] platform_drv_probe+0x48/0x90 | [ea837da0] [c0531c14] driver_probe_device+0x15c/0x2c4 | [ea837dd0] [c0531e04] __driver_attach+0x88/0xb0 | ---[ end trace ... ]--- The problem is caused by emac_dt_phy_probe() returing success (0) for existing device-trees configurations that do not specify a "phy-handle" property. This caused the code to skip the existing phy probe and setup. Which led to essential phy related data-structures being uninitialized. This patch also removes the unused variable in emac_dt_phy_connect(). Fixes: a577ca6 ("net: emac: add support for device-tree based PHY discovery and setup") Reported-by: Julian Margetson <[email protected]> Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 50ad480 commit b793f08

File tree

1 file changed

+17
-8
lines changed
  • drivers/net/ethernet/ibm/emac

1 file changed

+17
-8
lines changed

drivers/net/ethernet/ibm/emac/core.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,8 +2589,6 @@ static int emac_dt_mdio_probe(struct emac_instance *dev)
25892589
static int emac_dt_phy_connect(struct emac_instance *dev,
25902590
struct device_node *phy_handle)
25912591
{
2592-
int res;
2593-
25942592
dev->phy.def = devm_kzalloc(&dev->ofdev->dev, sizeof(*dev->phy.def),
25952593
GFP_KERNEL);
25962594
if (!dev->phy.def)
@@ -2617,7 +2615,7 @@ static int emac_dt_phy_probe(struct emac_instance *dev)
26172615
{
26182616
struct device_node *np = dev->ofdev->dev.of_node;
26192617
struct device_node *phy_handle;
2620-
int res = 0;
2618+
int res = 1;
26212619

26222620
phy_handle = of_parse_phandle(np, "phy-handle", 0);
26232621

@@ -2714,13 +2712,24 @@ static int emac_init_phy(struct emac_instance *dev)
27142712
if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) {
27152713
int res = emac_dt_phy_probe(dev);
27162714

2717-
mutex_unlock(&emac_phy_map_lock);
2718-
if (!res)
2715+
switch (res) {
2716+
case 1:
2717+
/* No phy-handle property configured.
2718+
* Continue with the existing phy probe
2719+
* and setup code.
2720+
*/
2721+
break;
2722+
2723+
case 0:
2724+
mutex_unlock(&emac_phy_map_lock);
27192725
goto init_phy;
27202726

2721-
dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n",
2722-
res);
2723-
return res;
2727+
default:
2728+
mutex_unlock(&emac_phy_map_lock);
2729+
dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n",
2730+
res);
2731+
return res;
2732+
}
27242733
}
27252734

27262735
if (dev->phy_address != 0xffffffff)

0 commit comments

Comments
 (0)