Skip to contentSkip to conversation

x86/platform/goldfish: add a check for platform_device_register_simple

PATCH Superseded Chuhong Yuan 2 participants 2 messages Dec 9, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/platform/goldfish: add a check for platform_device_register_simple

goldfish_init() misses a check for platform_device_register_simple(). Add a check to fix it.

Fixes ddd70cf93d78 ("goldfish: platform device for x86")
---
 arch/x86/platform/goldfish/goldfish.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
arch/x86/platform/goldfish/goldfish.c +7 -2
index 6b6f8b4360dd..e9694baf6e72 100644
@@ -44,11 +44,16 @@ __setup("goldfish", goldfish_setup);
 
 static int __init goldfish_init(void)
 {
+	struct platform_device *pdev;
+
 	if (!goldfish_enable)
 		return -ENODEV;
 
-	platform_device_register_simple("goldfish_pdev_bus", -1,
-					goldfish_pdev_bus_resources, 2);
+	pdev =  platform_device_register_simple("goldfish_pdev_bus", -1,
+					goldfish_pdev_bus_resources, 2);
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
+
 	return 0;
 }
 device_initcall(goldfish_init);
Signature · 1 line
2.24.0
#1 lore raw
Quoted 3 lines · Chuhong Yuan

goldfish_init() misses a check for platform_device_register_simple(). Add a check to fix it.

Thanks for a patch. My comments below.

arch/x86/platform/goldfish/goldfish.c __setup("goldfish", goldfish_setup); · line 52

Quoted 11 lines

static int __init goldfish_init(void)
{

arch/x86/platform/goldfish/goldfish.c +3 -2
+       struct platform_device *pdev;
+
        if (!goldfish_enable)
                return -ENODEV;
 
-       platform_device_register_simple("goldfish_pdev_bus", -1,
-                                       goldfish_pdev_bus_resources, 2);
 
+       pdev =  platform_device_register_simple("goldfish_pdev_bus", -1,

Perhaps idea for a separate patch or maybe here:
-1 -> PLATFORM_DEVID_NONE

arch/x86/platform/goldfish/goldfish.c __setup("goldfish", goldfish_setup); · line 57

Quoted 6 lines
arch/x86/platform/goldfish/goldfish.c +4 -0
+                                       goldfish_pdev_bus_resources, 2);
 
+       if (IS_ERR(pdev))
+               return PTR_ERR(pdev);
+
        return 0;

This can use PTR_ERR_OR_ZERO() macro instead.

Quoted 1 line

}

Signature · 2 lines
With Best Regards,
Andy Shevchenko