linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/platform/goldfish: add a check for platform_device_register_simple
@ 2019-12-09 16:22 Chuhong Yuan
  2019-12-09 17:55 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Chuhong Yuan @ 2019-12-09 16:22 UTC (permalink / raw)
  Cc: Darren Hart, Andy Shevchenko, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin, x86, Bruce Beare, Sheng Yang,
	Yunhong Jiang, Alan Cox, platform-driver-x86, linux-kernel,
	Chuhong Yuan

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

Fixes: ddd70cf93d78 ("goldfish: platform device for x86")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 arch/x86/platform/goldfish/goldfish.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/goldfish/goldfish.c b/arch/x86/platform/goldfish/goldfish.c
index 6b6f8b4360dd..e9694baf6e72 100644
--- a/arch/x86/platform/goldfish/goldfish.c
+++ b/arch/x86/platform/goldfish/goldfish.c
@@ -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);
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/platform/goldfish: add a check for platform_device_register_simple
  2019-12-09 16:22 [PATCH] x86/platform/goldfish: add a check for platform_device_register_simple Chuhong Yuan
@ 2019-12-09 17:55 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2019-12-09 17:55 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: Darren Hart, Andy Shevchenko, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H . Peter Anvin,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Bruce Beare, Sheng Yang, Yunhong Jiang, Alan Cox,
	Platform Driver, Linux Kernel Mailing List

On Mon, Dec 9, 2019 at 6:22 PM Chuhong Yuan <hslester96@gmail.com> wrote:
>
> goldfish_init() misses a check for platform_device_register_simple().
> Add a check to fix it.

Thanks for a patch. My comments below.

>  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,

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

> +                                       goldfish_pdev_bus_resources, 2);

> +       if (IS_ERR(pdev))
> +               return PTR_ERR(pdev);
> +
>         return 0;

This can use PTR_ERR_OR_ZERO() macro instead.

>  }


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-09 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 16:22 [PATCH] x86/platform/goldfish: add a check for platform_device_register_simple Chuhong Yuan
2019-12-09 17:55 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).