Skip to contentSkip to conversation

am300epd: Release platform device in case of platform_device_add_data() fails

PATCH In review Lin Yujun 1 participant 2 messages Sep 14, 2022 – Sep 26, 2022

Subsystems (3)
lore
Share & tools
lore

Lin Yujun

author
#0 lore raw

PATCH 1/1 am300epd: Release platform device in case of platform_device_add_data() fails

The platform device need to be released when platform_device_add_data() fails. Use platform_device_put() to release 'pdev' in error path.

Fixes 4ce255c1420d ("[ARM] 5354/1: mach-pxa: add AM300 platform driver v3")
---
 arch/arm/mach-pxa/am300epd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/am300epd.c +5 -2
index 4b55bc89db8f..f8542b6aa9b7 100644
@@ -275,11 +275,14 @@ int __init am300_init(void)
 		return -ENOMEM;
 
 	/* the am300_board that will be seen by broadsheetfb is a copy */
-	platform_device_add_data(am300_device, &am300_board,
+	ret = platform_device_add_data(am300_device, &am300_board,
 					sizeof(am300_board));
+	if (ret) {
+		platform_device_put(am300_device);
+		return ret;
+	}
 
 	ret = platform_device_add(am300_device);
-
 	if (ret) {
 		platform_device_put(am300_device);
 		return ret;
Signature · 1 line
2.17.1
#1 lore raw

kindly ping

Quoted 20 lines · Lin Yujun

The platform device need to be released when platform_device_add_data() fails. Use platform_device_put() to release 'pdev' in error path.

Fixes 4ce255c1420d ("[ARM] 5354/1: mach-pxa: add AM300 platform driver v3")
---
  arch/arm/mach-pxa/am300epd.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/mach-pxa/am300epd.c +1 -1
index 4b55bc89db8f..f8542b6aa9b7 100644
@@ -275,11 +275,14 @@ int __init am300_init(void)
  		return -ENOMEM;
 
  	/* the am300_board that will be seen by broadsheetfb is a copy */
-	platform_device_add_data(am300_device, &am300_board,
+	ret = platform_device_add_data(am300_device, &am300_board,
  					sizeof(am300_board));

arch/arm/mach-pxa/am300epd.c int __init am300_init(void) · line 288

Quoted 10 lines
arch/arm/mach-pxa/am300epd.c +4 -1
+	if (ret) {
+		platform_device_put(am300_device);
+		return ret;
+	}
 
  	ret = platform_device_add(am300_device);
-
  	if (ret) {
  		platform_device_put(am300_device);
  		return ret;

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel