* [PATCH] staging: gpib: cb7210: Add error handling
@ 2024-12-21 2:26 Nihar Chaithanya
2024-12-21 7:51 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Nihar Chaithanya @ 2024-12-21 2:26 UTC (permalink / raw)
To: dpenkler, gregkh, dan.carpenter, niharchaithanya, roheetchavan,
arnd, linux-staging, linux-kernel
Cc: skhan
The if condition in cb7210_init_module() would always fail as
the value of err is constantly 0.
Add error handling to cb_pcmcia_init_module() where it returns
appropriate error code if pcmcia_register_driver() fails.
This issue was reported by Coverity Scan.
Report:
CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: return -1;.
Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
drivers/staging/gpib/cb7210/cb7210.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index 63df7f3eb3f3..b2f6ad70ccaf 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -1353,7 +1353,11 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
int cb_pcmcia_init_module(void)
{
- pcmcia_register_driver(&cb_gpib_cs_driver);
+ int ret;
+
+ ret = pcmcia_register_driver(&cb_gpib_cs_driver);
+ if (ret < 0)
+ return ret;
return 0;
}
@@ -1528,9 +1532,10 @@ static int __init cb7210_init_module(void)
gpib_register_driver(&cb_pcmcia_unaccel_interface, THIS_MODULE);
err += cb_pcmcia_init_module();
#endif
- if (err)
+ if (err) {
+ pr_err("cb7210: registering PCMCIA driver with the bus core failed\n");
return -1;
-
+ }
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] staging: gpib: cb7210: Add error handling
2024-12-21 2:26 [PATCH] staging: gpib: cb7210: Add error handling Nihar Chaithanya
@ 2024-12-21 7:51 ` Greg KH
2024-12-21 8:36 ` Nihar Chaithanya
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2024-12-21 7:51 UTC (permalink / raw)
To: Nihar Chaithanya
Cc: dpenkler, dan.carpenter, roheetchavan, arnd, linux-staging,
linux-kernel, skhan
On Sat, Dec 21, 2024 at 07:56:33AM +0530, Nihar Chaithanya wrote:
> The if condition in cb7210_init_module() would always fail as
> the value of err is constantly 0.
> Add error handling to cb_pcmcia_init_module() where it returns
> appropriate error code if pcmcia_register_driver() fails.
>
> This issue was reported by Coverity Scan.
> Report:
>
> CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE)
> dead_error_line: Execution cannot reach this statement: return -1;.
>
> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
> ---
> drivers/staging/gpib/cb7210/cb7210.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
> index 63df7f3eb3f3..b2f6ad70ccaf 100644
> --- a/drivers/staging/gpib/cb7210/cb7210.c
> +++ b/drivers/staging/gpib/cb7210/cb7210.c
> @@ -1353,7 +1353,11 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
>
> int cb_pcmcia_init_module(void)
> {
> - pcmcia_register_driver(&cb_gpib_cs_driver);
> + int ret;
> +
> + ret = pcmcia_register_driver(&cb_gpib_cs_driver);
> + if (ret < 0)
> + return ret;
> return 0;
Why not make this whole function just one line? And then, as it's one
line, why is it a function at all?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] staging: gpib: cb7210: Add error handling
2024-12-21 7:51 ` Greg KH
@ 2024-12-21 8:36 ` Nihar Chaithanya
0 siblings, 0 replies; 3+ messages in thread
From: Nihar Chaithanya @ 2024-12-21 8:36 UTC (permalink / raw)
To: Greg KH
Cc: dpenkler, dan.carpenter, roheetchavan, arnd, linux-staging,
linux-kernel, skhan
On 21/12/24 13:21, Greg KH wrote:
> On Sat, Dec 21, 2024 at 07:56:33AM +0530, Nihar Chaithanya wrote:
>> The if condition in cb7210_init_module() would always fail as
>> the value of err is constantly 0.
>> Add error handling to cb_pcmcia_init_module() where it returns
>> appropriate error code if pcmcia_register_driver() fails.
>>
>> This issue was reported by Coverity Scan.
>> Report:
>>
>> CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE)
>> dead_error_line: Execution cannot reach this statement: return -1;.
>>
>> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
>> ---
>> drivers/staging/gpib/cb7210/cb7210.c | 11 ++++++++---
>> 1 file changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
>> index 63df7f3eb3f3..b2f6ad70ccaf 100644
>> --- a/drivers/staging/gpib/cb7210/cb7210.c
>> +++ b/drivers/staging/gpib/cb7210/cb7210.c
>> @@ -1353,7 +1353,11 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
>>
>> int cb_pcmcia_init_module(void)
>> {
>> - pcmcia_register_driver(&cb_gpib_cs_driver);
>> + int ret;
>> +
>> + ret = pcmcia_register_driver(&cb_gpib_cs_driver);
>> + if (ret < 0)
>> + return ret;
>> return 0;
> Why not make this whole function just one line? And then, as it's one
> line, why is it a function at all?
>
> thanks,
>
> greg k-h
Hi Greg, yes, this redundant cb_pcmcia_init_module() can be replaced with
pcmcia_register_driver() where it's being called. I'll send the version 2
making these changes.
Thank you,
Nihar
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-21 8:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-21 2:26 [PATCH] staging: gpib: cb7210: Add error handling Nihar Chaithanya
2024-12-21 7:51 ` Greg KH
2024-12-21 8:36 ` Nihar Chaithanya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox