tlclk: fix platform_device_register_simple() error check
Subsystems (2)
PATCH 1/1 tlclk: fix platform_device_register_simple() error check
The return value of platform_device_register_simple() should be checked by IS_ERR().
This patch also fix misc_register() error case. Because misc_register() returns error code.
--- drivers/char/tlclk.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/char/tlclk.c +2 -3
@@ -792,15 +792,14 @@ static int __init tlclk_init(void) ret =misc_register (&tlclk_miscdev);if (ret <0 ) {printk (KERN_ERR "tlclk: misc_register returns %d.\n" , ret); - ret = -EBUSY ; goto out3; } tlclk_device =platform_device_register_simple ("telco_clock" ,-1 ,NULL ,0 ); -if (!tlclk_device) { +if (IS_ERR (tlclk_device)) {printk (KERN_ERR "tlclk: platform_device_register failed.\n" ); - ret = -EBUSY ; + ret =PTR_ERR (tlclk_device); goto out4; }
Quoted 18 lines · Akinobu Mita
The return value of
platform_device_register_simple()should be checked byIS_ERR().This patch also fix
misc_register()error case. Becausemisc_register()returns error code.Cc Sebastien Bouchard <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- drivers/char/tlclk.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)Index:
work-fault-inject/drivers/char/tlclk.c
===================================================================
drivers/char/tlclk.c static int __init tlclk_init(void) · line 795
Quoted 4 lines
drivers/char/tlclk.c +0
-1@@ -792,15 +792,14 @@ static int __init tlclk_init(void) ret =misc_register (&tlclk_miscdev);if (ret <0 ) {printk (KERN_ERR "tlclk: misc_register returns %d.\n" , ret); - ret = -EBUSY ;
results in an non-error return when there this device isn't on the system.
* NAK *
drivers/char/tlclk.c static int __init tlclk_init(void) · line 800
Quoted 7 lines
drivers/char/tlclk.c +1
-1goto out3; } tlclk_device =platform_device_register_simple ("telco_clock" ,-1 ,NULL ,0 ); -if (!tlclk_device) { +if (IS_ERR (tlclk_device)) {
ok
drivers/char/tlclk.c static int __init tlclk_init(void) · line 802
Quoted 3 lines
drivers/char/tlclk.c +1
-1printk (KERN_ERR "tlclk: platform_device_register failed.\n" ); - ret = -EBUSY ; + ret =PTR_ERR (tlclk_device);
I don't know about this but I could be wrong. Please convince me.
Quoted 8 lines
drivers/char/tlclk.c +0
-1goto out4; } -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 27 lines · Mark Gross
Quoted 18 lines · Akinobu Mita
The return value of
platform_device_register_simple()should be checked byIS_ERR().This patch also fix
misc_register()error case. Becausemisc_register()returns error code.Cc Sebastien Bouchard <[email protected]>Signed-off-by Akinobu Mita <[email protected]>--- drivers/char/tlclk.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)Index:
work-fault-inject/drivers/char/tlclk.c
===================================================================drivers/char/tlclk.c static int __init tlclk_init(void) · line 795
Quoted 4 lines
drivers/char/tlclk.c +0
-1@@ -792,15 +792,14 @@ static int __init tlclk_init(void) ret =misc_register (&tlclk_miscdev);if (ret <0 ) {printk (KERN_ERR "tlclk: misc_register returns %d.\n" , ret); - ret = -EBUSY ;results in an non-error return when there this device isn't on the system.
Quoted 1 line
* NAK *
My bad. I was looking at the earlier ret = EBUSY, this is ok.
Quoted 28 lines
drivers/char/tlclk.c static int __init tlclk_init(void) · line 800
Quoted 7 lines
drivers/char/tlclk.c +1
-1goto out3; } tlclk_device =platform_device_register_simple ("telco_clock" ,-1 ,NULL ,0 ); -if (!tlclk_device) { +if (IS_ERR (tlclk_device)) {ok
drivers/char/tlclk.c static int __init tlclk_init(void) · line 802
Quoted 3 lines
drivers/char/tlclk.c +1
-1printk (KERN_ERR "tlclk: platform_device_register failed.\n" ); - ret = -EBUSY ; + ret =PTR_ERR (tlclk_device);I don't know about this but I could be wrong. Please convince me.
Quoted 8 lines
drivers/char/tlclk.c +0
-1goto out4; } -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 7 lines · Mark Gross
drivers/char/tlclk.c static int __init tlclk_init(void) · line 800
Quoted 5 lines
drivers/char/tlclk.c +1
-1tlclk_device =platform_device_register_simple ("telco_clock" ,-1 ,NULL ,0 ); -if (!tlclk_device) { +if (IS_ERR (tlclk_device)) {ok
Quoted 5 lines
drivers/char/tlclk.c static int __init tlclk_init(void) · line 802
Quoted 3 lines
drivers/char/tlclk.c +1
-1printk (KERN_ERR "tlclk: platform_device_register failed.\n" ); - ret = -EBUSY ; + ret =PTR_ERR (tlclk_device);I don't know about this but I could be wrong. Please convince me.
We expect platform_device_register_simple() returns proper errno as pointer when it fails.
Quoted 8 lines · Akinobu Mita
Quoted 7 lines · Mark Gross
drivers/char/tlclk.c static int __init tlclk_init(void) · line 800
Quoted 5 lines
drivers/char/tlclk.c +1
-1tlclk_device =platform_device_register_simple ("telco_clock" ,-1 ,NULL ,0 ); -if (!tlclk_device) { +if (IS_ERR (tlclk_device)) {ok
Quoted 8 lines
Quoted 5 lines
drivers/char/tlclk.c static int __init tlclk_init(void) · line 802
Quoted 3 lines
drivers/char/tlclk.c +1
-1printk (KERN_ERR "tlclk: platform_device_register failed.\n" ); - ret = -EBUSY ; + ret =PTR_ERR (tlclk_device);I don't know about this but I could be wrong. Please convince me.
We expect
platform_device_register_simple()returns proper errno as pointer when it fails.
What's wrong with EBUSY?
--mgross
Quoted 4 lines · Mark Gross
Quoted 2 lines
We expect
platform_device_register_simple()returns proper errno as pointer when it fails.What's wrong with EBUSY?
-ENOMEM or -EINVAL could be returned by platform_device_register_simple() logically. And we don't know what kind of change will be made into driver core in future.
Quoted 9 lines · Akinobu Mita
Quoted 4 lines · Mark Gross
Quoted 2 lines
We expect
platform_device_register_simple()returns proper errno as pointer when it fails.What's wrong with EBUSY?
-ENOMEMor-EINVALcould be returned byplatform_device_register_simple()logically. And we don't know what kind of change will be made into driver core in future.
Ok, would you like me to ack your earlier patch or will you send a new one?
--mgross
Quoted 5 lines · Mark Gross
Quoted 4 lines · Akinobu Mita
Quoted 3 lines · Mark Gross
Quoted 2 lines
We expect
platform_device_register_simple()returns proper errno as pointer when it fails.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
What's wrong with EBUSY?
-ENOMEMor-EINVALcould be returned byplatform_device_register_simple()logically. And we don't know what kind of change will be made into driver core in future.Ok, would you like me to ack your earlier patch or will you send a new one?
I'm working on an update to the tlclk driver to avoid a race in the open and read functions. Do you have any changes I should roll into the driver?
--mgross