Message ID | 20210528071056.35252-1-sriranjani.p@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: stmmac: fix kernel panic due to NULL pointer dereference of mdio_bus_data | expand |
On Fri, 28 May 2021 12:40:56 +0530 Sriranjani P wrote: > Fixed link does not need mdio bus and in that case mdio_bus_data will > not be allocated. Before using mdio_bus_data we should check for NULL. > > This patch fix the kernel panic due to NULL pointer dereference of > mdio_bus_data when it is not allocated. > > Without this patch we do see following kernel crash caused due to kernel > NULL pointer dereference. Applied, thanks.
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 5d956a553434..5d7688d02255 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1240,8 +1240,10 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) priv->phylink_config.dev = &priv->dev->dev; priv->phylink_config.type = PHYLINK_NETDEV; priv->phylink_config.pcs_poll = true; - priv->phylink_config.ovr_an_inband = - priv->plat->mdio_bus_data->xpcs_an_inband; + if (priv->plat->mdio_bus_data) { + priv->phylink_config.ovr_an_inband = + priv->plat->mdio_bus_data->xpcs_an_inband; + } if (!fwnode) fwnode = dev_fwnode(priv->device);