[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9058432a-a00c-49c3-824b-dd296970986a@linuxfoundation.org>
Date: Thu, 26 Dec 2024 13:43:16 -0700
From: Shuah Khan <skhan@...uxfoundation.org>
To: Nihar Chaithanya <niharchaithanya@...il.com>, dpenkler@...il.com,
gregkh@...uxfoundation.org
Cc: dan.carpenter@...aro.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org, Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH v4 02/15] staging: gpib: agilent_82350b: Handle
gpib_register_driver() errors
On 12/26/24 12:36, Nihar Chaithanya wrote:
> The function gpib_register_driver() can fail which can result in
> semi-registered module.
>
> In case gpib_register_driver() fails unregister the previous
> gpib and pci registering functions, return the error value.
>
> Signed-off-by: Nihar Chaithanya <niharchaithanya@...il.com>
> ---
> .../gpib/agilent_82350b/agilent_82350b.c | 21 ++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
> index 53006d0cc79c..39420f2b0b32 100644
> --- a/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
> +++ b/drivers/staging/gpib/agilent_82350b/agilent_82350b.c
> @@ -909,14 +909,25 @@ static int __init agilent_82350b_init_module(void)
> int result;
>
> result = pci_register_driver(&agilent_82350b_pci_driver);
> - if (result) {
> - pr_err("agilent_82350b: pci_driver_register failed!\n");
Is there a reason to delete this message?
> + if (result)
> return result;
> - }
>
> - gpib_register_driver(&agilent_82350b_unaccel_interface, THIS_MODULE);
> - gpib_register_driver(&agilent_82350b_interface, THIS_MODULE);
> + result = gpib_register_driver(&agilent_82350b_unaccel_interface, THIS_MODULE);
> + if (result)
> + goto err_unaccel;
> +
> + result = gpib_register_driver(&agilent_82350b_interface, THIS_MODULE);
> + if (result)
> + goto err_interface;
> +
> return 0;
> +
> +err_interface:
> + gpib_unregister_driver(&agilent_82350b_unaccel_interface);
> +err_unaccel:
> + pci_unregister_driver(&agilent_82350b_pci_driver);
> +
> + return result;
> }
>
> static void __exit agilent_82350b_exit_module(void)
thanks,
-- Shuah
Powered by blists - more mailing lists