[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241226193637.241049-7-niharchaithanya@gmail.com>
Date: Fri, 27 Dec 2024 01:06:30 +0530
From: Nihar Chaithanya <niharchaithanya@...il.com>
To: dpenkler@...il.com,
gregkh@...uxfoundation.org
Cc: dan.carpenter@...aro.org,
skhan@...uxfoundation.org,
linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Nihar Chaithanya <niharchaithanya@...il.com>
Subject: [PATCH v4 06/15] staging: gpib: fluke: Handle gpib_register_driver() errors
The function gpib_register_driver() can fail, resulting in a
semi-registered module and does not return an error value if it
fails.
Unregister the previous platform driver and gpib registering
functions if subsequent gpib_register_driver() fail and return the
error value.
Signed-off-by: Nihar Chaithanya <niharchaithanya@...il.com>
---
drivers/staging/gpib/eastwood/fluke_gpib.c | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/gpib/eastwood/fluke_gpib.c b/drivers/staging/gpib/eastwood/fluke_gpib.c
index 3f938ab0c84d..2efc0226ec2b 100644
--- a/drivers/staging/gpib/eastwood/fluke_gpib.c
+++ b/drivers/staging/gpib/eastwood/fluke_gpib.c
@@ -1154,17 +1154,31 @@ static int __init fluke_init_module(void)
int result;
result = platform_driver_register(&fluke_gpib_platform_driver);
- if (result) {
- pr_err("fluke_gpib: platform_driver_register failed!\n");
+ if (result)
return result;
- }
- gpib_register_driver(&fluke_unaccel_interface, THIS_MODULE);
- gpib_register_driver(&fluke_hybrid_interface, THIS_MODULE);
- gpib_register_driver(&fluke_interface, THIS_MODULE);
+ result = gpib_register_driver(&fluke_unaccel_interface, THIS_MODULE);
+ if (result)
+ goto err_unaccel;
+
+ result = gpib_register_driver(&fluke_hybrid_interface, THIS_MODULE);
+ if (result)
+ goto err_hybrid;
+
+ result = gpib_register_driver(&fluke_interface, THIS_MODULE);
+ if (result)
+ goto err_interface;
- pr_info("fluke_gpib\n");
return 0;
+
+err_interface:
+ gpib_unregister_driver(&fluke_hybrid_interface);
+err_hybrid:
+ gpib_unregister_driver(&fluke_unaccel_interface);
+err_unaccel:
+ platform_driver_unregister(&fluke_gpib_platform_driver);
+
+ return result;
}
static void __exit fluke_exit_module(void)
--
2.34.1
Powered by blists - more mailing lists