dpaa2-eth: check fsl_mc_get_endpoint for IS_ERR_OR_NULL()
authorIoana Ciornei <ioana.ciornei@nxp.com>
Tue, 14 Jul 2020 12:08:16 +0000 (15:08 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 08:19:41 +0000 (10:19 +0200)
[ Upstream commit 841eb4012cef84820e5906527b31a854f42b0748 ]

The fsl_mc_get_endpoint() function can return an error or directly a
NULL pointer in case the peer device is not under the root DPRC
container. Treat this case also, otherwise it would lead to a NULL
pointer when trying to access the peer fsl_mc_device.

Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

index 569e06d2bab21a08f8e6645545a01a1f29153ccf..72fa9c4e058f72e45d7a0720546fddb8d7aa1d08 100644 (file)
@@ -3383,7 +3383,7 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
 
        dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
        dpmac_dev = fsl_mc_get_endpoint(dpni_dev);
-       if (IS_ERR(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
+       if (IS_ERR_OR_NULL(dpmac_dev) || dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type)
                return 0;
 
        if (dpaa2_mac_is_type_fixed(dpmac_dev, priv->mc_io))