Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6281ad2 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Greg Kroah-Hartman
Browse files

phy: samsung: exynos5250-sata: fix missing device put in probe error paths



[ Upstream commit 5c8402c4db45dd55c2c93c8d730f5dfa7c78a702 ]

The actions of of_find_i2c_device_by_node() in probe function should be
reversed in error paths by putting the reference to obtained device.

Fixes: bcff4cba ("PHY: Exynos: Add Exynos5250 SATA PHY driver")
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Link: https://lore.kernel.org/r/20220407091857.230386-2-krzysztof.kozlowski@linaro.org


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c1283432
Loading
Loading
Loading
Loading
+14 −6
Original line number Original line Diff line number Diff line
@@ -202,20 +202,21 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
	sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl");
	sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl");
	if (IS_ERR(sata_phy->phyclk)) {
	if (IS_ERR(sata_phy->phyclk)) {
		dev_err(dev, "failed to get clk for PHY\n");
		dev_err(dev, "failed to get clk for PHY\n");
		return PTR_ERR(sata_phy->phyclk);
		ret = PTR_ERR(sata_phy->phyclk);
		goto put_dev;
	}
	}


	ret = clk_prepare_enable(sata_phy->phyclk);
	ret = clk_prepare_enable(sata_phy->phyclk);
	if (ret < 0) {
	if (ret < 0) {
		dev_err(dev, "failed to enable source clk\n");
		dev_err(dev, "failed to enable source clk\n");
		return ret;
		goto put_dev;
	}
	}


	sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops);
	sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops);
	if (IS_ERR(sata_phy->phy)) {
	if (IS_ERR(sata_phy->phy)) {
		clk_disable_unprepare(sata_phy->phyclk);
		dev_err(dev, "failed to create PHY\n");
		dev_err(dev, "failed to create PHY\n");
		return PTR_ERR(sata_phy->phy);
		ret = PTR_ERR(sata_phy->phy);
		goto clk_disable;
	}
	}


	phy_set_drvdata(sata_phy->phy, sata_phy);
	phy_set_drvdata(sata_phy->phy, sata_phy);
@@ -223,11 +224,18 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)
	phy_provider = devm_of_phy_provider_register(dev,
	phy_provider = devm_of_phy_provider_register(dev,
					of_phy_simple_xlate);
					of_phy_simple_xlate);
	if (IS_ERR(phy_provider)) {
	if (IS_ERR(phy_provider)) {
		clk_disable_unprepare(sata_phy->phyclk);
		ret = PTR_ERR(phy_provider);
		return PTR_ERR(phy_provider);
		goto clk_disable;
	}
	}


	return 0;
	return 0;

clk_disable:
	clk_disable_unprepare(sata_phy->phyclk);
put_dev:
	put_device(&sata_phy->client->dev);

	return ret;
}
}


static const struct of_device_id exynos_sata_phy_of_match[] = {
static const struct of_device_id exynos_sata_phy_of_match[] = {