PCI: dra7xx: Added error handling in probe function when devm_phy_get() fails
PATCH v2 1/1 PCI: dra7xx: Added error handling in probe function when devm_phy_get() fails
While creation of device link, if devm_phy_get() function fails then it directly returns PTR_ERR without any cleanup of previous added device links.
Added goto statement to handle the cleanup of already added device links.
PCIe and PHY)
---
v2: resend when tree is open and reformat commit message
drivers/pci/controller/dwc/pci-dra7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +4 -2
@@ -762,8 +762,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)for (i =0 ; i < phy_count; i++) {snprintf (name,sizeof (name),"pcie-phy%d" , i); phy[i] =devm_phy_get (dev, name); -if (IS_ERR (phy[i])) -return PTR_ERR (phy[i]); +if (IS_ERR (phy[i])) { + ret =PTR_ERR (phy[i]); + goto err_link; + } link[i] =device_link_add (dev, &phy[i]->dev,DL_FLAG_STATELESS );if (!link[i]) {
Signature · 1 line
2.46.1
Quoted 9 lines · Riyan Dhiman
While creation of device link, if
devm_phy_get()function fails then it directly returnsPTR_ERRwithout any cleanup of previous added device links.Added goto statement to handle the cleanup of already added device links.
Fixes 7a4db656a635 (PCI: dra7xx: Create functional dependency betweenPCIe and PHY)
Signed-off-by Riyan Dhiman <[email protected]>
No need to repost for this, but when applying, please s/Added/Add/ in subject and commit log (I mentioned this before for the v1 posting).
Also add statement in commit log about what the patch does (currently it only says what the problem is).
And join Fixes: into a single line without a newline in the middle.
Quoted 26 lines
---
v2: resend when tree is open and reformat commit messagedrivers/pci/controller/dwc/pci-dra7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/pci/controller/dwc/pci-dra7xx.c +4
-2@@ -762,8 +762,10 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)for (i =0 ; i < phy_count; i++) {snprintf (name,sizeof (name),"pcie-phy%d" , i); phy[i] =devm_phy_get (dev, name); -if (IS_ERR (phy[i])) -return PTR_ERR (phy[i]); +if (IS_ERR (phy[i])) { + ret =PTR_ERR (phy[i]); + goto err_link; + } link[i] =device_link_add (dev, &phy[i]->dev,DL_FLAG_STATELESS );if (!link[i]) {Signature · 1 line
2.46.1