Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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: bcff4cba41bc ("PHY: Exynos: Add Exynos5250 SATA PHY driver")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Link: https://lore.kernel.org/r/20220407091857.230386-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
5c8402c4 388ec8f0

+14 -6
+14 -6
drivers/phy/samsung/phy-exynos5250-sata.c
··· 196 196 sata_phy->phyclk = devm_clk_get(dev, "sata_phyctrl"); 197 197 if (IS_ERR(sata_phy->phyclk)) { 198 198 dev_err(dev, "failed to get clk for PHY\n"); 199 - return PTR_ERR(sata_phy->phyclk); 199 + ret = PTR_ERR(sata_phy->phyclk); 200 + goto put_dev; 200 201 } 201 202 202 203 ret = clk_prepare_enable(sata_phy->phyclk); 203 204 if (ret < 0) { 204 205 dev_err(dev, "failed to enable source clk\n"); 205 - return ret; 206 + goto put_dev; 206 207 } 207 208 208 209 sata_phy->phy = devm_phy_create(dev, NULL, &exynos_sata_phy_ops); 209 210 if (IS_ERR(sata_phy->phy)) { 210 - clk_disable_unprepare(sata_phy->phyclk); 211 211 dev_err(dev, "failed to create PHY\n"); 212 - return PTR_ERR(sata_phy->phy); 212 + ret = PTR_ERR(sata_phy->phy); 213 + goto clk_disable; 213 214 } 214 215 215 216 phy_set_drvdata(sata_phy->phy, sata_phy); ··· 218 217 phy_provider = devm_of_phy_provider_register(dev, 219 218 of_phy_simple_xlate); 220 219 if (IS_ERR(phy_provider)) { 221 - clk_disable_unprepare(sata_phy->phyclk); 222 - return PTR_ERR(phy_provider); 220 + ret = PTR_ERR(phy_provider); 221 + goto clk_disable; 223 222 } 224 223 225 224 return 0; 225 + 226 + clk_disable: 227 + clk_disable_unprepare(sata_phy->phyclk); 228 + put_dev: 229 + put_device(&sata_phy->client->dev); 230 + 231 + return ret; 226 232 } 227 233 228 234 static const struct of_device_id exynos_sata_phy_of_match[] = {