From: Nihar Chaithanya <niharchaithanya@gmail.com>
To: dpenkler@gmail.com, gregkh@linuxfoundation.org
Cc: dan.carpenter@linaro.org, skhan@linuxfoundation.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Nihar Chaithanya <niharchaithanya@gmail.com>
Subject: [PATCH v6 03/15] staging: gpib: agilent_82357a: Handle gpib_register_driver() errors
Date: Tue, 31 Dec 2024 00:26:23 +0530 [thread overview]
Message-ID: <20241230185633.175690-4-niharchaithanya@gmail.com> (raw)
In-Reply-To: <20241230185633.175690-1-niharchaithanya@gmail.com>
The usb_register() function can fail and returns an error value which
is not returned. The function gpib_register_driver() can also fail
which can result in semi-registered module.
In case gpib_register_driver() fails unregister the previous usb driver
registering function. Return the error value if gpib_register_driver()
or usb_register() functions fail. Add pr_err when registering driver
fails also indicating the error value.
Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
---
.../staging/gpib/agilent_82357a/agilent_82357a.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
index bf05fb4a736b..261fb6d2e991 100644
--- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
+++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c
@@ -1691,12 +1691,24 @@ static struct usb_driver agilent_82357a_bus_driver = {
static int __init agilent_82357a_init_module(void)
{
int i;
+ int ret;
pr_info("agilent_82357a_gpib driver loading");
for (i = 0; i < MAX_NUM_82357A_INTERFACES; ++i)
agilent_82357a_driver_interfaces[i] = NULL;
- usb_register(&agilent_82357a_bus_driver);
- gpib_register_driver(&agilent_82357a_gpib_interface, THIS_MODULE);
+
+ ret = usb_register(&agilent_82357a_bus_driver);
+ if (ret) {
+ pr_err("agilent_82357a: usb_register failed: error = %d\n", ret);
+ return ret;
+ }
+
+ ret = gpib_register_driver(&agilent_82357a_gpib_interface, THIS_MODULE);
+ if (ret) {
+ pr_err("agilent_82357a: gpib_register_driver failed: error = %d\n", ret);
+ usb_deregister(&agilent_82357a_bus_driver);
+ return ret;
+ }
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2024-12-30 19:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-30 18:56 [PATCH v6 00/15] staging: gpib: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 01/15] staging: gpib: Modify gpib_register_driver() to return error if it fails Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 02/15] staging: gpib: agilent_82350b: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-30 18:56 ` Nihar Chaithanya [this message]
2024-12-30 18:56 ` [PATCH v6 04/15] staging: gpib: cb7210: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 05/15] staging: gpib: cec: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 06/15] staging: gpib: fluke: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 07/15] staging: gpib: fmh: " Nihar Chaithanya
2024-12-31 4:13 ` kernel test robot
2024-12-30 18:56 ` [PATCH v6 08/15] staging: gpib: gpio: Return error value from gpib_register_driver() Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 09/15] staging: gpib: hp_82335: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 10/15] staging: gpib: hp_82341: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 11/15] staging: gpib: ines: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 12/15] staging: gpib: lpvo_usb: Return error value from gpib_register_driver() Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 13/15] staging: gpib: ni_usb: Handle gpib_register_driver() errors Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 14/15] staging: gpib: pc2: " Nihar Chaithanya
2024-12-30 18:56 ` [PATCH v6 15/15] staging: gpib: tnt4882: " Nihar Chaithanya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241230185633.175690-4-niharchaithanya@gmail.com \
--to=niharchaithanya@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=dpenkler@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox