Return-Path: From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Alexey Khoroshilov , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 11/52] net: phy: xgene: disable clk on error paths Date: Sat, 3 Feb 2018 18:03:39 +0000 Message-ID: <20180203180303.8490-11-alexander.levin@microsoft.com> References: <20180203180303.8490-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180303.8490-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: From: Alexey Khoroshilov [ Upstream commit ab14436065c8066c265540312742390d6d07ddd2 ] There are several error paths in xgene_mdio_probe(), where clk is left undisabled. The patch fixes them. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/phy/mdio-xgene.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/mdio-xgene.c b/drivers/net/phy/mdio-xgene.c index 92af182951be..8eb077b677f6 100644 --- a/drivers/net/phy/mdio-xgene.c +++ b/drivers/net/phy/mdio-xgene.c @@ -197,8 +197,11 @@ static int xgene_mdio_reset(struct xgene_mdio_pdata *p= data) } =20 ret =3D xgene_enet_ecc_init(pdata); - if (ret) + if (ret) { + if (pdata->dev->of_node) + clk_disable_unprepare(pdata->clk); return ret; + } xgene_gmac_reset(pdata); =20 return 0; @@ -364,8 +367,10 @@ static int xgene_mdio_probe(struct platform_device *pd= ev) return ret; =20 mdio_bus =3D mdiobus_alloc(); - if (!mdio_bus) - return -ENOMEM; + if (!mdio_bus) { + ret =3D -ENOMEM; + goto out_clk; + } =20 mdio_bus->name =3D "APM X-Gene MDIO bus"; =20 @@ -394,7 +399,7 @@ static int xgene_mdio_probe(struct platform_device *pde= v) mdio_bus->phy_mask =3D ~0; ret =3D mdiobus_register(mdio_bus); if (ret) - goto out; + goto out_mdiobus; =20 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_HANDLE(dev), 1, acpi_register_phy, NULL, mdio_bus, NULL); @@ -402,16 +407,20 @@ static int xgene_mdio_probe(struct platform_device *p= dev) } =20 if (ret) - goto out; + goto out_mdiobus; =20 pdata->mdio_bus =3D mdio_bus; xgene_mdio_status =3D true; =20 return 0; =20 -out: +out_mdiobus: mdiobus_free(mdio_bus); =20 +out_clk: + if (dev->of_node) + clk_disable_unprepare(pdata->clk); + return ret; } =20 --=20 2.11.0