Re: [PATCH -next] pxa: Release platform device in case of platform_device_add() fails.

From
linyujun (C) <hidden>
Date
2022-09-26 09:14:39
Also in
lkml
Reply to
Lin Yujun, 2022-09-14
kindly ping

在 2022/9/14 11:24, Lin Yujun 写道:
quoted hunk ↗ jump to hunk
The platform device is not released when platform_device_add()
fails. Use platform_device_put() to release these resource.

Fixes: 49cbe78637eb ("[ARM] pxa: add base support for Marvell's PXA168 processor line")
Signed-off-by: Lin Yujun <redacted>
---
  arch/arm/mach-mmp/devices.c | 21 ++++++++++++---------
  1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c
index 79f4a2aa5475..e918f419bc4c 100644
--- a/arch/arm/mach-mmp/devices.c
+++ b/arch/arm/mach-mmp/devices.c
@@ -53,20 +53,23 @@ int __init mmp_register_device(struct mmp_device_desc *desc,
  	}
  
  	ret = platform_device_add_resources(pdev, res, nres);
-	if (ret) {
-		platform_device_put(pdev);
-		return ret;
-	}
+	if (ret)
+		goto err_put_pdev;
  
  	if (data && size) {
  		ret = platform_device_add_data(pdev, data, size);
-		if (ret) {
-			platform_device_put(pdev);
-			return ret;
-		}
+		if (ret)
+			goto err_put_pdev;
  	}
  
-	return platform_device_add(pdev);
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err_put_pdev;
+	return ret;
+
+err_put_pdev:
+	platform_device_put(pdev);
+	return ret;
  }
  
  #if IS_ENABLED(CONFIG_USB) || IS_ENABLED(CONFIG_USB_GADGET)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Thread (2 messages) 2 messages, 1 author, last reply 2022-09-26
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help