From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bl2nam02on0134.outbound.protection.outlook.com ([104.47.38.134]:35168 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752816AbeBCSAx (ORCPT ); Sat, 3 Feb 2018 13:00:53 -0500 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.14 022/110] net: phy: xgene: disable clk on error paths Date: Sat, 3 Feb 2018 18:00:37 +0000 Message-ID: <20180203180015.29073-22-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-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: stable-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 bfd3090fb055..07c6048200c6 100644 --- a/drivers/net/phy/mdio-xgene.c +++ b/drivers/net/phy/mdio-xgene.c @@ -194,8 +194,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; @@ -388,8 +391,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 @@ -418,7 +423,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); @@ -426,16 +431,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