From: Venkatesh Yadav Abbarapu Date: Thu, 29 Sep 2022 04:56:05 +0000 (+0530) Subject: net: Fix static checker warnings X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=9a082d2548de523c37f035cee7e0c280bad62bee;p=u-boot.git net: Fix static checker warnings Here are the smatch warning messages: drivers/net/xilinx_axi_emac.c:324 axiemac_phy_init() error: 'phydev' dereferencing possible ERR_PTR() drivers/net/zynq_gem.c:340 zynq_phy_init() error: 'priv->phydev' dereferencing possible ERR_PTR() Fix by adding error checking before dereferencing the pointer. Signed-off-by: Venkatesh Yadav Abbarapu Link: https://lore.kernel.org/r/20220929045605.23964-1-venkatesh.abbarapu@amd.com Signed-off-by: Michal Simek --- diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index d48e342ea0..5f5bc650be 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -317,6 +318,10 @@ static int axiemac_phy_init(struct udevice *dev) /* Interface - look at tsec */ phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); + if (IS_ERR_OR_NULL(phydev)) { + dev_err(dev, "phy_connect() failed\n"); + return -ENODEV; + } phydev->supported &= supported; phydev->advertising = phydev->supported; diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 61a6c83e33..3f4357ec80 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -328,7 +328,7 @@ static int zynq_phy_init(struct udevice *dev) priv->phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); - if (!priv->phydev) + if (IS_ERR_OR_NULL(priv->phydev)) return -ENODEV; if (priv->max_speed) {