Skip to content

Commit e87d3a1

Browse files
Yanteng Sidavem330
authored andcommitted
stmmac: dwmac-loongson: Make sure MDIO is initialized before use
Generic code will use mdio. If it is not initialized before use, the kernel will Oops. Fixes: 30bba69 ("stmmac: pci: Add dwmac support for Loongson") Signed-off-by: Yanteng Si <[email protected]> Signed-off-by: Feiyang Chen <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f3f32a3 commit e87d3a1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,15 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
6868
if (!plat)
6969
return -ENOMEM;
7070

71+
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
72+
sizeof(*plat->mdio_bus_data),
73+
GFP_KERNEL);
74+
if (!plat->mdio_bus_data)
75+
return -ENOMEM;
76+
7177
plat->mdio_node = of_get_child_by_name(np, "mdio");
7278
if (plat->mdio_node) {
7379
dev_info(&pdev->dev, "Found MDIO subnode\n");
74-
75-
plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
76-
sizeof(*plat->mdio_bus_data),
77-
GFP_KERNEL);
78-
if (!plat->mdio_bus_data) {
79-
ret = -ENOMEM;
80-
goto err_put_node;
81-
}
8280
plat->mdio_bus_data->needs_reset = true;
8381
}
8482

0 commit comments

Comments
 (0)