* [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
@ 2012-08-15 20:42 Alexey Khoroshilov
2012-08-15 21:00 ` Lars Hanisch
2012-08-16 9:26 ` Mauro Carvalho Chehab
0 siblings, 2 replies; 6+ messages in thread
From: Alexey Khoroshilov @ 2012-08-15 20:42 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Alexey Khoroshilov, linux-media, linux-kernel, ldv-project
If pci_register_driver() failed, resources allocated in
ddb_class_create() are leaked. The patch fixes it.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
index ebf3f05..36aa4e4 100644
--- a/drivers/media/dvb/ddbridge/ddbridge-core.c
+++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
@@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void)
"Copyright (C) 2010-11 Digital Devices GmbH\n");
if (ddb_class_create())
return -1;
- return pci_register_driver(&ddb_pci_driver);
+ if (pci_register_driver(&ddb_pci_driver) < 0) {
+ ddb_class_destroy();
+ return -1;
+ }
+ return 0;
}
static __exit void module_exit_ddbridge(void)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
2012-08-15 20:42 [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge() Alexey Khoroshilov
@ 2012-08-15 21:00 ` Lars Hanisch
2012-08-15 23:13 ` Mauro Carvalho Chehab
2012-08-16 9:26 ` Mauro Carvalho Chehab
1 sibling, 1 reply; 6+ messages in thread
From: Lars Hanisch @ 2012-08-15 21:00 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, ldv-project
Hi,
Am 15.08.2012 22:42, schrieb Alexey Khoroshilov:
> If pci_register_driver() failed, resources allocated in
> ddb_class_create() are leaked. The patch fixes it.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
> index ebf3f05..36aa4e4 100644
> --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
> +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
> @@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void)
> "Copyright (C) 2010-11 Digital Devices GmbH\n");
> if (ddb_class_create())
> return -1;
> - return pci_register_driver(&ddb_pci_driver);
> + if (pci_register_driver(&ddb_pci_driver) < 0) {
> + ddb_class_destroy();
> + return -1;
Difference to before: the return value of pci_register_driver is not passed through.
Is this a problem? I'm just an interested application developer, not a driver developer.
Regards,
Lars.
> + }
> + return 0;
> }
>
> static __exit void module_exit_ddbridge(void)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
2012-08-15 21:00 ` Lars Hanisch
@ 2012-08-15 23:13 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2012-08-15 23:13 UTC (permalink / raw)
To: Lars Hanisch
Cc: Alexey Khoroshilov, Mauro Carvalho Chehab, linux-media,
linux-kernel, ldv-project
Em 15-08-2012 18:00, Lars Hanisch escreveu:
> Hi,
>
> Am 15.08.2012 22:42, schrieb Alexey Khoroshilov:
>> If pci_register_driver() failed, resources allocated in
>> ddb_class_create() are leaked. The patch fixes it.
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> ---
>> drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
>> index ebf3f05..36aa4e4 100644
>> --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
>> +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
>> @@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void)
>> "Copyright (C) 2010-11 Digital Devices GmbH\n");
>> if (ddb_class_create())
>> return -1;
This is not right. It should be returning a proper error code.
Could you please patch ddb_class_create() in order to make it to
return the retuned value from IS_ERR() as the error code, and return
it back to the init code?
Ok, I noticed that other parts of the driver are also returning wrong
error codes, but let's fix at least module_init_ddbridge() while you're
looking into this.
>> - return pci_register_driver(&ddb_pci_driver);
>> + if (pci_register_driver(&ddb_pci_driver) < 0) {
>> + ddb_class_destroy();
>> + return -1;
Again, the correct here would be to store the error on a temp register
and return it, instead of returning -1.
>
> Difference to before: the return value of pci_register_driver is not passed through.
> Is this a problem? I'm just an interested application developer, not a driver developer.
On userspace, ioctl() always return -1 on errors. The error code at "errno"
is wrong, though. Instead of "1", it should be the ones described at the
API spec[1].
[1] http://linuxtv.org/downloads/v4l-dvb-apis/gen_errors.html
>
> Regards,
> Lars.
>
>> + }
>> + return 0;
>> }
>>
>> static __exit void module_exit_ddbridge(void)
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
2012-08-15 20:42 [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge() Alexey Khoroshilov
2012-08-15 21:00 ` Lars Hanisch
@ 2012-08-16 9:26 ` Mauro Carvalho Chehab
2012-08-16 9:36 ` Mauro Carvalho Chehab
1 sibling, 1 reply; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2012-08-16 9:26 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, ldv-project
Em 15-08-2012 17:42, Alexey Khoroshilov escreveu:
> If pci_register_driver() failed, resources allocated in
> ddb_class_create() are leaked. The patch fixes it.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
> index ebf3f05..36aa4e4 100644
> --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
> +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
> @@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void)
> "Copyright (C) 2010-11 Digital Devices GmbH\n");
> if (ddb_class_create())
> return -1;
This is not right. It should be returning a proper error code.
Could you please patch ddb_class_create() in order to make it to
return the retuned value from IS_ERR() as the error code, and return
it back to the init code?
Ok, I noticed that other parts of the driver are also returning wrong
error codes, but let's fix at least module_init_ddbridge() while you're
looking into this.
> - return pci_register_driver(&ddb_pci_driver);
> + if (pci_register_driver(&ddb_pci_driver) < 0) {
> + ddb_class_destroy();
> + return -1;
The correct here would be to store the error on a temp register
and return it, instead of returning -1.
> + }
> + return 0;
> }
>
> static __exit void module_exit_ddbridge(void)
>
Thank you!
Mauro
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
2012-08-16 9:26 ` Mauro Carvalho Chehab
@ 2012-08-16 9:36 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 6+ messages in thread
From: Mauro Carvalho Chehab @ 2012-08-16 9:36 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, ldv-project
Em 16-08-2012 06:26, Mauro Carvalho Chehab escreveu:
> Em 15-08-2012 17:42, Alexey Khoroshilov escreveu:
>> If pci_register_driver() failed, resources allocated in
>> ddb_class_create() are leaked. The patch fixes it.
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
>> ---
>> drivers/media/dvb/ddbridge/ddbridge-core.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
>> index ebf3f05..36aa4e4 100644
>> --- a/drivers/media/dvb/ddbridge/ddbridge-core.c
>> +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
>> @@ -1705,7 +1705,11 @@ static __init int module_init_ddbridge(void)
>> "Copyright (C) 2010-11 Digital Devices GmbH\n");
>> if (ddb_class_create())
>> return -1;
>
> This is not right. It should be returning a proper error code.
Please discard this email. I already commented this on a previous email.
This one was a previous draft.
Thanks,
Mauro
>
> Could you please patch ddb_class_create() in order to make it to
> return the retuned value from IS_ERR() as the error code, and return
> it back to the init code?
>
> Ok, I noticed that other parts of the driver are also returning wrong
> error codes, but let's fix at least module_init_ddbridge() while you're
> looking into this.
>
>> - return pci_register_driver(&ddb_pci_driver);
>> + if (pci_register_driver(&ddb_pci_driver) < 0) {
>> + ddb_class_destroy();
>> + return -1;
>
> The correct here would be to store the error on a temp register
> and return it, instead of returning -1.
>
>> + }
>> + return 0;
>> }
>>
>> static __exit void module_exit_ddbridge(void)
>>
>
> Thank you!
> Mauro
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge()
@ 2012-08-16 21:05 Alexey Khoroshilov
0 siblings, 0 replies; 6+ messages in thread
From: Alexey Khoroshilov @ 2012-08-16 21:05 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Alexey Khoroshilov, linux-media, linux-kernel, ldv-project
If pci_register_driver() failed, resources allocated in
ddb_class_create() are leaked. The patch fixes it
as well as it replaces -1 with correct error code
in ddb_class_create().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/media/dvb/ddbridge/ddbridge-core.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c
index ebf3f05..feff57e 100644
--- a/drivers/media/dvb/ddbridge/ddbridge-core.c
+++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
@@ -1497,7 +1497,7 @@ static int ddb_class_create(void)
ddb_class = class_create(THIS_MODULE, DDB_NAME);
if (IS_ERR(ddb_class)) {
unregister_chrdev(ddb_major, DDB_NAME);
- return -1;
+ return PTR_ERR(ddb_class);
}
ddb_class->devnode = ddb_devnode;
return 0;
@@ -1701,11 +1701,18 @@ static struct pci_driver ddb_pci_driver = {
static __init int module_init_ddbridge(void)
{
+ int ret;
+
printk(KERN_INFO "Digital Devices PCIE bridge driver, "
"Copyright (C) 2010-11 Digital Devices GmbH\n");
- if (ddb_class_create())
- return -1;
- return pci_register_driver(&ddb_pci_driver);
+
+ ret = ddb_class_create();
+ if (ret < 0)
+ return ret;
+ ret = pci_register_driver(&ddb_pci_driver);
+ if (ret < 0)
+ ddb_class_destroy();
+ return ret;
}
static __exit void module_exit_ddbridge(void)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-16 21:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-15 20:42 [PATCH] [media] ddbridge: fix error handling in module_init_ddbridge() Alexey Khoroshilov
2012-08-15 21:00 ` Lars Hanisch
2012-08-15 23:13 ` Mauro Carvalho Chehab
2012-08-16 9:26 ` Mauro Carvalho Chehab
2012-08-16 9:36 ` Mauro Carvalho Chehab
2012-08-16 21:05 Alexey Khoroshilov
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).