Skip to contentSkip to conversation

leds: mlxcpld: fix return value check in mlxcpld_led_init()

PATCH In review Wei Yongjun 3 participants 4 messages Sep 13, 2016 – Sep 14, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: mlxcpld: fix return value check in mlxcpld_led_init()

From: Wei Yongjun <[email protected]>

In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

---
 drivers/leds/leds-mlxcpld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-mlxcpld.c +2 -2
index 125ddfa..2ba76c1 100644
@@ -401,9 +401,9 @@ static int __init mlxcpld_led_init(void)
 	int err;
 
 	pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
-	if (!pdev) {
+	if (IS_ERR(pdev)) {
 		pr_err("Device allocation failed\n");
-		return -ENOMEM;
+		return PTR_ERR(pdev);
 	}
 
 	err = platform_driver_probe(&mlxcpld_led_driver, mlxcpld_led_probe);
#1 lore raw

Hi Wei,

Quoted 21 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function platform_device_register_simple() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

---
 drivers/leds/leds-mlxcpld.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-mlxcpld.c +0 -0
index 125ddfa..2ba76c1 100644
@@ -401,9 +401,9 @@ static int __init mlxcpld_led_init(void)
 	int err;

drivers/leds/leds-mlxcpld.c static int __init mlxcpld_led_init(void) · line 409

Quoted 10 lines
drivers/leds/leds-mlxcpld.c +2 -2
 
 	pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
-	if (!pdev) {
+	if (IS_ERR(pdev)) {
 		pr_err("Device allocation failed\n");
-		return -ENOMEM;
+		return PTR_ERR(pdev);
 	}
 
 	err = platform_driver_probe(&mlxcpld_led_driver, mlxcpld_led_probe);

Thanks for your patches. Would you mind if I merged them to the original patch and added your Reviewed-by tag to the commit message?

Signature · 2 lines
Best regards,
Jacek Anaszewski
#2 lore raw

Hi Jacek,

Quoted 8 lines

-----Original Message-----
From: Jacek Anaszewski [mailto:[email protected]]
Sent: Wednesday, September 14, 2016 2:56 PM
To: Wei Yongjun; Vadim Pasternak; Richard Purdie
Cc: weiyongjun (A); [email protected]
Subject: Re: [PATCH -next] leds: mlxcpld: fix return value check in mlxcpld_led_init()

Quoted 5 lines

Hi Wei,

Thanks for your patches. Would you mind if I merged them to the original patch and added your Reviewed-by tag to the commit message?

Feel free to merge them, it is ok with me.

Regards,
Yongjun Wei

Reviewed-by Wei Yongjun
#3 lore raw
Quoted 10 lines · weiyongjun (A)

Hi Jacek,

Quoted 8 lines

-----Original Message-----
From: Jacek Anaszewski [mailto:[email protected]]
Sent: Wednesday, September 14, 2016 2:56 PM
To: Wei Yongjun; Vadim Pasternak; Richard Purdie
Cc: weiyongjun (A); [email protected]
Subject: Re: [PATCH -next] leds: mlxcpld: fix return value check in mlxcpld_led_init()

Quoted 7 lines
Quoted 5 lines

Hi Wei,

Thanks for your patches. Would you mind if I merged them to the original patch and added your Reviewed-by tag to the commit message?

Feel free to merge them, it is ok with me.

Patches merged. I added also to the commit message the tag:

Signature · 2 lines
Best regards,
Jacek Anaszewski